boost: fix segfault in asio+align module.

Reported-by: Érico Nogueira <erico.erc@gmail.com>
This commit is contained in:
Đoàn Trần Công Danh 2022-09-11 23:28:08 +07:00
parent 4ee660b607
commit 5df7a377f7
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,32 @@
boost/align/aligned_alloc.hpp is wrong, it uses feature test macros to
determine whether something is available;
FTMs shouldn't be in user code outside of top level #define's.
This lead to an issue on musl where libtorrent-rasterbar was including this
header (via boost asio) from two different places, and segfaulting due to
mismatched implementations -- one's the posix one using posix_memalign, the
other one's the generic one that stores a pointer to itself.
posix_memalign is always available on the libcs we support and should always be
used, so we force that. We still leave applications with the option of forcing
boost specific behavior, if they really want it.
Instead of patching only boost/align/aligned_alloc.hpp, which fix the
bug if boost::asio is used, but may keep other boost's code use feature tests
macro, now or later, let's patch boost/config.hpp to always define
_XOPEN_SOURCE instead.
--- a/boost/config.hpp
+++ b/boost/config.hpp
@@ -17,6 +17,11 @@
#ifndef BOOST_CONFIG_HPP
#define BOOST_CONFIG_HPP
+#ifdef __linux__
+/* for _XOPEN_SOURCE and/or _POSIX_C_SOURCE */
+#include <features.h>
+#endif
+
// if we don't have a user config, then use the default location:
#if !defined(BOOST_USER_CONFIG) && !defined(BOOST_NO_USER_CONFIG)
# define BOOST_USER_CONFIG <boost/config/user.hpp>

View File

@ -1,7 +1,7 @@
# Template file for 'boost'
pkgname=boost
version=1.80.0
revision=1
revision=2
wrksrc="${pkgname}_${version//\./_}"
hostmakedepends="which bzip2-devel icu-devel python3-devel pkg-config"
makedepends="zlib-devel bzip2-devel icu-devel python3-devel liblzma-devel