From 06d3b4b7138cabe411a51bf79f90889193aae017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 7 Sep 2022 17:32:19 -0300 Subject: [PATCH 1/5] boost: fix segfault in asio+align module. --- srcpkgs/boost/patches/align.patch | 28 ++++++++++++++++++++++++++++ srcpkgs/boost/template | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/boost/patches/align.patch diff --git a/srcpkgs/boost/patches/align.patch b/srcpkgs/boost/patches/align.patch new file mode 100644 index 000000000000..e3de2159cf6e --- /dev/null +++ b/srcpkgs/boost/patches/align.patch @@ -0,0 +1,28 @@ +This code is wrong and 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. + +diff --git a/boost/align/aligned_alloc.hpp b/boost/align/aligned_alloc.hpp +index 1d81a13..f2b5137 100644 +--- a/boost/align/aligned_alloc.hpp ++++ b/boost/align/aligned_alloc.hpp +@@ -38,10 +38,8 @@ Distributed under the Boost Software License, Version 1.0. + #include + #elif defined(sun) || defined(__sun) + #include +-#elif (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600) +-#include + #else +-#include ++#include + #endif + + #endif diff --git a/srcpkgs/boost/template b/srcpkgs/boost/template index 0d103e335b52..ef383d7f85ed 100644 --- a/srcpkgs/boost/template +++ b/srcpkgs/boost/template @@ -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 From 93f57033f43927af037047d7fb111699ff7aae39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Nogueira?= Date: Wed, 7 Sep 2022 17:34:19 -0300 Subject: [PATCH 2/5] libtorrent-rasterbar: rebuild to fix segfault. Since asio is a header-only library, we need to rebuild its dependents. --- srcpkgs/libtorrent-rasterbar/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/libtorrent-rasterbar/template b/srcpkgs/libtorrent-rasterbar/template index 52377b39eca4..135d89b9c85a 100644 --- a/srcpkgs/libtorrent-rasterbar/template +++ b/srcpkgs/libtorrent-rasterbar/template @@ -2,7 +2,7 @@ # Breaks ABI/API without changing soname, revbump all dependants pkgname=libtorrent-rasterbar version=1.2.17 -revision=1 +revision=2 build_style=cmake configure_args="DCMAKE_CXX_STANDARD=14 -Dbuild_examples=ON -Dbuild_tools=ON -Dpython-bindings=ON" From 58b4da4968dbfd556a4c0ae9b732e9820154c9bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Fri, 9 Sep 2022 08:54:11 +0700 Subject: [PATCH 3/5] fixup! boost: fix segfault in asio+align module. --- srcpkgs/boost/patches/align.patch | 38 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/srcpkgs/boost/patches/align.patch b/srcpkgs/boost/patches/align.patch index e3de2159cf6e..99e4fb2a1c5e 100644 --- a/srcpkgs/boost/patches/align.patch +++ b/srcpkgs/boost/patches/align.patch @@ -1,5 +1,6 @@ -This code is wrong and uses feature test macros to determine whether something -is available; FTMs shouldn't be in user code outside of top level #define's. +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 @@ -10,19 +11,22 @@ 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. -diff --git a/boost/align/aligned_alloc.hpp b/boost/align/aligned_alloc.hpp -index 1d81a13..f2b5137 100644 ---- a/boost/align/aligned_alloc.hpp -+++ b/boost/align/aligned_alloc.hpp -@@ -38,10 +38,8 @@ Distributed under the Boost Software License, Version 1.0. - #include - #elif defined(sun) || defined(__sun) - #include --#elif (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600) --#include - #else --#include -+#include - #endif +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 - #endif ++#ifdef __linux__ +++/* for features.h, which will define _XOPEN_SOURCE or _POSIX_C_SOURCE */ ++#include ++#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 From 5880f7b12c9c9d38f717105cf652b5a7a46f2ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Fri, 9 Sep 2022 08:56:41 +0700 Subject: [PATCH 4/5] fixup! fixup! boost: fix segfault in asio+align module. --- .../boost/{patches/align.patch => feature-test-macros.patch} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename srcpkgs/boost/{patches/align.patch => feature-test-macros.patch} (94%) diff --git a/srcpkgs/boost/patches/align.patch b/srcpkgs/boost/feature-test-macros.patch similarity index 94% rename from srcpkgs/boost/patches/align.patch rename to srcpkgs/boost/feature-test-macros.patch index 99e4fb2a1c5e..d674cd903e66 100644 --- a/srcpkgs/boost/patches/align.patch +++ b/srcpkgs/boost/feature-test-macros.patch @@ -23,7 +23,7 @@ _XOPEN_SOURCE instead. #define BOOST_CONFIG_HPP +#ifdef __linux__ -++/* for features.h, which will define _XOPEN_SOURCE or _POSIX_C_SOURCE */ +++/* for _XOPEN_SOURCE and/or _POSIX_C_SOURCE */ +#include +#endif + From 0bbad84e2fd16ffd1bf28ab237dcdf356002f4fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Fri, 9 Sep 2022 13:34:15 +0700 Subject: [PATCH 5/5] fixup! fixup! fixup! boost: fix segfault in asio+align module. --- srcpkgs/boost/{ => patches}/feature-test-macros.patch | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename srcpkgs/boost/{ => patches}/feature-test-macros.patch (100%) diff --git a/srcpkgs/boost/feature-test-macros.patch b/srcpkgs/boost/patches/feature-test-macros.patch similarity index 100% rename from srcpkgs/boost/feature-test-macros.patch rename to srcpkgs/boost/patches/feature-test-macros.patch