From 470adc93b2b9bca4bd1666f23683406da152dd86 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Sat, 1 Oct 2016 18:24:13 +0200 Subject: [PATCH] libunwind: update to 1.2rc1. Includes AArch64 support, no stable upstream release in 4 years. --- common/shlibs | 1 + .../libunwind/patches/x86_64-mincore.patch | 71 +++++++++++++++++++ srcpkgs/libunwind/template | 13 ++-- 3 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 srcpkgs/libunwind/patches/x86_64-mincore.patch diff --git a/common/shlibs b/common/shlibs index 8758817393..160eea78e9 100644 --- a/common/shlibs +++ b/common/shlibs @@ -1219,6 +1219,7 @@ libunwind-x86_64.so.8 libunwind-1.1_1 libunwind-x86.so.8 libunwind-1.1_1 libunwind-arm.so.8 libunwind-1.1_4 libunwind-mips.so.8 libunwind-1.1_4 +libunwind-aarch64.so.8 libunwind-1.2rc1_1 libmicrohttpd.so.12 libmicrohttpd-0.9.48_1 libgit2.so.24 libgit2-0.24.0_1 libgit2-glib-1.0.so.0 libgit2-glib-0.23.4_1 diff --git a/srcpkgs/libunwind/patches/x86_64-mincore.patch b/srcpkgs/libunwind/patches/x86_64-mincore.patch new file mode 100644 index 0000000000..d490c7744c --- /dev/null +++ b/srcpkgs/libunwind/patches/x86_64-mincore.patch @@ -0,0 +1,71 @@ +From bc8698fd7ed13a629a8ec3cb2a89bd74f9d8b5c0 Mon Sep 17 00:00:00 2001 +From: Giuseppe Ottaviano +Date: Sun, 20 Mar 2016 00:28:03 +0000 +Subject: [PATCH] x86_64: fix mincore_validate + +The detection logic introduced in 28f33c8ce0b654cf31d6beda9a612870662f3c56 is +broken, because it tests mincore using an address that is almost certainly not +page-aligned. straces confirms that msync is used all the time. + +This patch fixes the logic by page-aligning the test pointer. strace now shows +that mincore is actually used. Furthermore, the return value of mincore is not +sufficient to assess whether the address can be safely dereferenced: we should +also check that the pages are mapped, through the passed mvec array. This patch +also adds this verification. + +Tested on a system where unwinding a stack across a JNI boundary would cause +sporadic segfaults; no more crashes were observed after the patch. +--- + src/x86_64/Ginit.c | 24 ++++++++++++++++++++++-- + 1 file changed, 22 insertions(+), 2 deletions(-) + +--- src/x86_64/Ginit.c ++++ src/x86_64/Ginit.c +@@ -30,6 +30,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ + #include + #endif + ++#include + #include + #include + #include +@@ -81,7 +82,21 @@ static int msync_validate (void *addr, size_t len) + static int mincore_validate (void *addr, size_t len) + { + unsigned char mvec[2]; /* Unaligned access may cross page boundary */ +- return mincore (addr, len, mvec); ++ size_t i; ++ ++ /* mincore could fail with EAGAIN but we conservatively return -1 ++ instead of looping. */ ++ if (mincore (addr, len, mvec) != 0) ++ { ++ return -1; ++ } ++ ++ for (i = 0; i < (len + PAGE_SIZE - 1) / PAGE_SIZE; i++) ++ { ++ if (!(mvec[i] & 1)) return -1; ++ } ++ ++ return 0; + } + #endif + +@@ -94,7 +109,12 @@ tdep_init_mem_validate (void) + { + #ifdef HAVE_MINCORE + unsigned char present = 1; +- if (mincore (&present, 1, &present) == 0) ++ unw_word_t addr = PAGE_START((unw_word_t)&present); ++ unsigned char mvec[1]; ++ int ret; ++ while ((ret = mincore ((void*)addr, PAGE_SIZE, mvec)) == -1 && ++ errno == EAGAIN) {} ++ if (ret == 0 && (mvec[0] & 1)) + { + Debug(1, "using mincore to validate memory\n"); + mem_validate_func = mincore_validate; +-- +cgit v1.0 + diff --git a/srcpkgs/libunwind/template b/srcpkgs/libunwind/template index 5eed8d1d2e..f00e138982 100644 --- a/srcpkgs/libunwind/template +++ b/srcpkgs/libunwind/template @@ -1,20 +1,19 @@ # Template file for 'libunwind'. pkgname=libunwind -version=1.1 -revision=6 +version=1.2rc1 +revision=1 +wrksrc="${pkgname}-${version/rc/-rc}" build_style=gnu-configure hostmakedepends="libtool automake" makedepends="liblzma-devel" -short_desc="Portable and efficient C programming interface (API) to determine the call-chain of a program" +short_desc="Library to determine the call-chain of a program" maintainer="Juan RP " homepage="http://www.nongnu.org/libunwind/" license="MIT" -distfiles="http://download.savannah.gnu.org/releases/$pkgname/$pkgname-$version.tar.gz" -checksum=9dfe0fcae2a866de9d3942c66995e4b460230446887dbdab302d41a8aee8d09a +distfiles="http://download.savannah.gnu.org/releases/$pkgname/$pkgname-${version/rc/-rc}.tar.gz" +checksum=d222f186b6bc60f49dac5030516ec35a7ed0ccca675551d6cf81008112116abc pre_configure() { - # https://lists.gnu.org/archive/html/libunwind-devel/2014-06/msg00024.html - sed -i /LIBCRTS/s/-lgcc/-lgcc_s/ configure.ac sed -i /SUBDIRS/s/tests// Makefile.am autoreconf -fi }