Package: libunwind Version: 1.0.1-4 Severity: normal Tags: patch User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu raring ubuntu-patch
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Dear Maintainer, In Ubuntu, the attached patch was applied to achieve the following: * Enable test suite for amd64 architecture: + d/rules: Execute test suite when building for amd64 only. + d/patches/20122307_fix_setjmp.patch: Cherry picked fix from upstream VCS to fixup setjmp test failure. + d/patches/20123007_disable_known_test_failures.patch: Disable *-dyn1 tests as they use unsupported features on amd64. + d/patches/20123007_workaround_ltest-nocalloc.patch: Make dummy call to do_backtrace to ensure that malloc is not called post thread init. + d/patches/20123007_workaround_test-ptrace.patch: Walk default test arguments to ensure child process has visibility. The libunwind test suite is only really usable on amd64 but it serves as a useful canary for any core integration issues. Thanks for considering the patch. - -- System Information: Debian Release: wheezy/sid APT prefers quantal-updates APT policy: (500, 'quantal-updates'), (500, 'quantal-security'), (500, 'quantal') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 3.5.0-19-generic (SMP w/8 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJQwOUvAAoJEL/srsug59jDmeEP/jXBaUkqlmG0CuMFqJ7qEiPk dA3yw0Do2Cjjj+/Ju1L9F2vS5vI17b/aDHql4OgY677tA1YET7G4rJvG53AVtldz OL4O0EaPtbce0XtzWAHM8AEjVlgoiyBclQtzK3QinZTFf9ymAjYx4pLl3p+VacY2 z1KS/TWMklgrdTbuDMISf4yLVdTaQ5Omkd9cROf3xwIvww3wf0wwQ41u+MhAD+Uk 34vL8nczVWD/kbSru7u0t/tV4mkljBdD+PHAZraPB+XOkz65u3FKPbn7piIgRttz U1JiSSA5QOyWfd/HEt8cHLimH/EZ+IzdalBlzNOWugfx1d0aZsEb7VAn+LnOU3/g AprDr52UfvTKUMCa92MDKlZcTRsvE/IPLVwpuOnPTCKG0ExrbVqNEs/BAiAIvwnV Fvu03ERedK+9U3trHsCqDPLvinQmyZ8HvlcnUu+ySp0jGLHhafpLqr+Pcee7GtG4 WkdcCbyp0imFqwegWpFad5wE43pYKUeSAB+fPxgUzGA1mmocTccAAMDDdKUAmMG6 DfTdaw3OiUW7I1XBEuPsxFgbGhj1cac/L4KttrnkCnP0bxD5XZdbyvIErpC7alqa Qjl0JQig14BaYi+CUTahwVPxzgVNmAmJqK6UOv0wBozGk5ZqB6GQpsBmF/dmil4R gEx8JYfh3QwBnBu9LtFf =eeth -----END PGP SIGNATURE-----
diff -Nru libunwind-1.0.1/debian/changelog libunwind-1.0.1/debian/changelog diff -Nru libunwind-1.0.1/debian/patches/20122307_fix_setjmp.patch libunwind-1.0.1/debian/patches/20122307_fix_setjmp.patch --- libunwind-1.0.1/debian/patches/20122307_fix_setjmp.patch 1970-01-01 01:00:00.000000000 +0100 +++ libunwind-1.0.1/debian/patches/20122307_fix_setjmp.patch 2012-07-30 10:10:02.000000000 +0100 @@ -0,0 +1,109 @@ +From 297d9cd07d7ea9b541fb13bffe418c8b2a8c3aa6 Mon Sep 17 00:00:00 2001 +From: Paul Pluzhnikov <ppluzhni...@google.com> +Date: Tue, 15 Nov 2011 07:45:09 +0000 +Subject: Fix for failing test-setjmp + +On Mon, Nov 14, 2011 at 5:02 PM, Paul Pluzhnikov <ppluzhni...@google.com> wrote: + +> P.S. test-setjmp is failing for me (before or after the patch). +> When I enable assertions (to confirm my new assertions are correct), I see: +> +> lt-test-setjmp: ../../src/dwarf/Gparser.c:754: apply_reg_state: \ +> Assertion `rs->reg[17].where == DWARF_WHERE_EXPR' failed. +> +> which likely explains that failure. + +The problem is actually two-fold: + +First, the loops in {sig,}longjmp.c are "do { ... } while (unw_step() >= 0);" + +But unw_step() returns 0 on reaching the end of the chain (_start), +and the loop should stop there. + +The second problem is that with this commit: + http://repo.or.cz/w/glibc.git/commitdiff/c67da0b50e3d20f89d7bb352cd67dcf66d808e50 +glibc obfuscates value of SP in jmp_buf, so we might as well just give up. + +Patch attached. + +Thanks, +-- +Paul Pluzhnikov +--- +Index: libunwind/src/setjmp/longjmp.c +=================================================================== +--- libunwind.orig/src/setjmp/longjmp.c 2012-07-23 10:59:17.449688000 +0100 ++++ libunwind/src/setjmp/longjmp.c 2012-07-23 11:00:31.632589776 +0100 +@@ -34,6 +34,20 @@ + #include "jmpbuf.h" + #include "setjmp_i.h" + ++#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 4) ++ ++/* Starting with glibc-2.4, {sig,}setjmp in GLIBC obfuscates the ++ register values in jmp_buf by XORing them with a "random" ++ canary value. ++ ++ This makes it impossible to implement longjmp, as we ++ can never match wp[JB_SP], unless we decode the canary first. ++ ++ Doing so is possible, but doesn't appear to be worth the trouble, ++ so we simply defer to glibc longjmp here. */ ++ ++#else ++ + void + _longjmp (jmp_buf env, int val) + { +@@ -74,7 +88,7 @@ + + abort (); + } +- while (unw_step (&c) >= 0); ++ while (unw_step (&c) > 0); + + abort (); + } +@@ -89,4 +103,6 @@ + _longjmp (env, val); + } + ++#endif /* __GLIBC__ */ ++ + #endif +Index: libunwind/src/setjmp/siglongjmp.c +=================================================================== +--- libunwind.orig/src/setjmp/siglongjmp.c 2012-07-23 10:59:17.449688000 +0100 ++++ libunwind/src/setjmp/siglongjmp.c 2012-07-23 11:00:31.632589776 +0100 +@@ -35,6 +35,20 @@ + # define _NSIG (_SIG_MAXSIG - 1) + #endif + ++#if defined(__GLIBC__) && __GLIBC_PREREQ(2, 4) ++ ++/* Starting with glibc-2.4, {sig,}setjmp in GLIBC obfuscates the ++ register values in jmp_buf by XORing them with a "random" ++ canary value. ++ ++ This makes it impossible to implement longjmp, as we ++ can never match wp[JB_SP], unless we decode the canary first. ++ ++ Doing so is possible, but doesn't appear to be worth the trouble, ++ so we simply defer to glibc siglongjmp here. */ ++ ++#else ++ + void + siglongjmp (sigjmp_buf env, int val) + { +@@ -96,7 +110,9 @@ + + abort (); + } +- while (unw_step (&c) >= 0); ++ while (unw_step (&c) > 0); + + abort (); + } ++ ++#endif /* __GLIBC__ */ diff -Nru libunwind-1.0.1/debian/patches/20123007_disable_known_test_failures.patch libunwind-1.0.1/debian/patches/20123007_disable_known_test_failures.patch --- libunwind-1.0.1/debian/patches/20123007_disable_known_test_failures.patch 1970-01-01 01:00:00.000000000 +0100 +++ libunwind-1.0.1/debian/patches/20123007_disable_known_test_failures.patch 2012-07-30 12:09:41.000000000 +0100 @@ -0,0 +1,19 @@ +Description: Some tests within the libunwind test suite + are known failures (see Origin and README for verification of this). + . + The package currently only executes tests for amd64: + - *-dyn1 tests use feature which are not avaliable on this arch +Origin: http://lists.nongnu.org/archive/html/libunwind-devel/2012-07/msg00005.html + +Index: libunwind/tests/Makefile.am +=================================================================== +--- libunwind.orig/tests/Makefile.am 2012-07-30 10:05:35.271168000 +0100 ++++ libunwind/tests/Makefile.am 2012-07-30 11:57:02.332769610 +0100 +@@ -41,7 +41,6 @@ + Gtest-init Ltest-init \ + Gtest-concurrent Ltest-concurrent \ + Gtest-resume-sig Ltest-resume-sig \ +- Gtest-dyn1 Ltest-dyn1 \ + Gtest-trace Ltest-trace \ + test-async-sig test-flush-cache test-init-remote \ + test-mem test-setjmp test-ptrace \ diff -Nru libunwind-1.0.1/debian/patches/20123007_workaround_ltest-nocalloc.patch libunwind-1.0.1/debian/patches/20123007_workaround_ltest-nocalloc.patch --- libunwind-1.0.1/debian/patches/20123007_workaround_ltest-nocalloc.patch 1970-01-01 01:00:00.000000000 +0100 +++ libunwind-1.0.1/debian/patches/20123007_workaround_ltest-nocalloc.patch 2012-07-30 10:21:11.000000000 +0100 @@ -0,0 +1,22 @@ +Description: Make dummy call to backtrace from thread creation to ensure + that libunwind per-thread state only gets initialized once resulting + in no futher calls to calloc. + . + This can create issues if libunwind is being used within a signal handler + (such as provided by google-perftools). +Origin: https://groups.google.com/forum/#!msg/google-perftools/Df10Uy4Djrg/XzbESvLZhiYJ +Forwarded: not-needed + +Index: libunwind/tests/Gtest-nocalloc.c +=================================================================== +--- libunwind.orig/tests/Gtest-nocalloc.c 2012-07-30 10:05:35.271168000 +0100 ++++ libunwind/tests/Gtest-nocalloc.c 2012-07-30 10:17:34.794107721 +0100 +@@ -123,6 +123,8 @@ + if (pthread_key_create (&key, NULL)) + panic ("FAILURE: unable to create key %d\n", i); + } ++ do_backtrace(); ++ num_mallocs = num_callocs = 0; + foo1 (); + num_errors = num_mallocs + num_callocs; + if (num_errors > 0) diff -Nru libunwind-1.0.1/debian/patches/20123007_workaround_test-ptrace.patch libunwind-1.0.1/debian/patches/20123007_workaround_test-ptrace.patch --- libunwind-1.0.1/debian/patches/20123007_workaround_test-ptrace.patch 1970-01-01 01:00:00.000000000 +0100 +++ libunwind-1.0.1/debian/patches/20123007_workaround_test-ptrace.patch 2012-07-30 11:39:41.000000000 +0100 @@ -0,0 +1,16 @@ +Index: libunwind/tests/test-ptrace.c +=================================================================== +--- libunwind.orig/tests/test-ptrace.c 2012-07-30 10:05:35.271168000 +0100 ++++ libunwind/tests/test-ptrace.c 2012-07-30 11:39:37.309158623 +0100 +@@ -182,6 +182,11 @@ + + /* automated test case */ + argv = args; ++ ++ /* Unless the args array is 'walked' the child ++ process is unable to access it and dies with a segfault */ ++ fprintf(stderr, "Automated test (%s,%s,%s,%s)\n", ++ args[0],args[1],args[2],args[3]); + } + else if (argc > 1) + while (argv[optind][0] == '-') diff -Nru libunwind-1.0.1/debian/patches/series libunwind-1.0.1/debian/patches/series --- libunwind-1.0.1/debian/patches/series 2012-09-17 06:32:11.000000000 +0100 +++ libunwind-1.0.1/debian/patches/series 2012-12-06 18:31:40.000000000 +0000 @@ -2,3 +2,7 @@ 20120422_tests_Makefile_am.patch 20120704_fix_arm_ftbfs.patch 20120707_ia64_FTBFS.patch +20122307_fix_setjmp.patch +20123007_workaround_ltest-nocalloc.patch +20123007_disable_known_test_failures.patch +20123007_workaround_test-ptrace.patch diff -Nru libunwind-1.0.1/debian/rules libunwind-1.0.1/debian/rules --- libunwind-1.0.1/debian/rules 2012-09-17 06:32:11.000000000 +0100 +++ libunwind-1.0.1/debian/rules 2012-11-14 11:22:58.000000000 +0000 @@ -5,7 +5,6 @@ #export DH_VERBOSE=1 export DEB_BUILD_MAINT_OPTIONS = hardening=-all,+format -DEB_BUILD_OPTIONS=nocheck %: dh $@ --parallel --with autoreconf @@ -22,6 +21,15 @@ override_dh_installchangelogs: dh_installchangelogs ChangeLog +override_dh_auto_test: +ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) +# Test suite is only useful on amd64 architecture; +# other ARCH's have quite a few know test faulures. +ifeq (amd64, $(DEB_BUILD_ARCH)) + $(MAKE) check +endif # amd64 +endif # nocheck + override_dh_strip: dh_strip -plibunwind8 --dbg-package=libunwind8-dbg dh_strip -plibunwind-setjmp0 --dbg-package=libunwind-setjmp0-dbg