Package: google-perftools Version: 2.0-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 execution during package build process: - d/rules: Execute check target after build, restrict test execution to amd64 and i386 architectures only. - d/p/20120725_heap-check-after-destructors.patch: Always run heap check after destructors as atexit ordering is no longer deterministic. - d/p/20120725_ptrace-permissions.patch: Ensure child process can ptrace parent pid when heap checking. - d/p/20123107_fix_i386_frames.patch: Cherry picked fix from upstream VCS to ensure stacks can be traced on i386 architecture. * d/p/20121206_syscall-support.patch: Cherry pick from upstream VCS to fix FTBFS due to type conversion mis-match. The test suite is only run for i386 and amd64; but does serve as a canary for the general quality of the codebase. 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) iQIcBAEBCAAGBQJQwN0hAAoJEL/srsug59jD1x0P/0ThP6xnQwt3A1A3SmniCBP6 aAxBDsPc1UoV29OcTG2d3Yuc8aGuyUWp+DQ7vfq6iEhenK+kyGoDjA2HcMuuty2Z uxrLI+IdqSTmS6Gl5Tq6V3hgi52AqeQ7Ctx1xIGFeeN1v7XO2NtG5HNbsF046TD8 pV5XCapCZcQO3dovTglI1dDg3/6syYU2xrYWLVcqiZ+uJxQZEi0WuP0iv350+xrB q6oed5RkxofI6A09N5LZCDx+Iz/aIXSlLPc9hwYKVspFyDTqaojeSHKnx+MOPkO5 E+H+6nMpjeWgpdWUUOaVPASoAEpZ60XoKhwtF6ZDUJJftyFwLlXwF59YmmOYq/rx /UDg3aBp7BOGt05yohvb+gwSdTaPmroqXQuj6uibwu2p8QxE98NpzxjIvpxKQvzl DfFEV5S40A0OechucyMFTwFPAKTFMrJED480pK5lUB9FR77R9z9Nxrv6pHdVuENI /nJN7dV2Lb0vj/l5o8tPgw+/d5/pldgSK2rXWUU7o3wsjo0uhQNIeRmX5FW3fRob ZAdaHON2bddICQ2CL9kmDxxJlNsbl5fGT8rbVtr0tlP+pxOaNleqho0Pbyr1qZjF MJpl4mVnOBXjAJyHJ3TM5IU7pQhVIQ0iqVRhtZm6mqnywiJ+3vEHMkB6GQuMtCrf zM85XSR8g+qNoqDdMfU3 =Pq8e -----END PGP SIGNATURE-----
diff -u google-perftools-2.0/debian/rules google-perftools-2.0/debian/rules --- google-perftools-2.0/debian/rules +++ google-perftools-2.0/debian/rules @@ -19,6 +19,14 @@ DEB_AUTO_UPDATE_LIBTOOL = pre DEB_INSTALL_CHANGELOGS_ALL := ChangeLog +ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS))) +# List of architectures for which test execution is enabled +TEST_ARCHS=i386 amd64 +ifneq (,$(findstring $(DEB_HOST_ARCH), $(TEST_ARCHS))) +DEB_MAKE_CHECK_TARGET := check +endif # TEST_ARCHS +endif # nocheck + lib_dir = usr/lib bin_dir = usr/bin man_dir = usr/share/man/man1 diff -u google-perftools-2.0/debian/changelog google-perftools-2.0/debian/changelog only in patch2: unchanged: --- google-perftools-2.0.orig/debian/patches/20120725_ptrace-permissions.patch +++ google-perftools-2.0/debian/patches/20120725_ptrace-permissions.patch @@ -0,0 +1,145 @@ +Description: Ensure that child process can ptrace parent before + executing the heap check. +Author: James Page <james.p...@ubuntu.com> +Forwarded: http://code.google.com/p/gperftools/issues/detail?id=437 + +Index: src/base/linuxthreads.cc +=================================================================== +--- src/base/linuxthreads.cc (revision 151) ++++ src/base/linuxthreads.cc (working copy) +@@ -45,6 +45,8 @@ + #include <fcntl.h> + #include <sys/socket.h> + #include <sys/wait.h> ++#include <sys/prctl.h> ++#include <semaphore.h> + + #include "base/linux_syscall_support.h" + #include "base/thread_lister.h" +@@ -240,6 +242,7 @@ + ListAllProcessThreadsCallBack callback; + void *parameter; + va_list ap; ++ sem_t *lock; + }; + + +@@ -254,6 +257,13 @@ + struct kernel_stat marker_sb, proc_sb; + stack_t altstack; + ++ /* Wait for parent thread to set appropriate permissions ++ * to allow ptrace activity ++ */ ++ if (sem_wait(args->lock) < 0) { ++ goto failure; ++ } ++ + /* Create "marker" that we can use to detect threads sharing the same + * address space and the same file handles. By setting the FD_CLOEXEC flag + * we minimize the risk of misidentifying child processes as threads; +@@ -536,6 +546,7 @@ + pid_t clone_pid; + int dumpable = 1, sig; + struct kernel_sigset_t sig_blocked, sig_old; ++ sem_t lock; + + va_start(args.ap, callback); + +@@ -565,6 +576,7 @@ + args.altstack_mem = altstack_mem; + args.parameter = parameter; + args.callback = callback; ++ args.lock = &lock; + + /* Before cloning the thread lister, block all asynchronous signals, as we */ + /* are not prepared to handle them. */ +@@ -596,42 +608,59 @@ + #undef SYS_LINUX_SYSCALL_SUPPORT_H + #include "linux_syscall_support.h" + #endif +- +- int clone_errno; +- clone_pid = local_clone((int (*)(void *))ListerThread, &args); +- clone_errno = errno; + +- sys_sigprocmask(SIG_SETMASK, &sig_old, &sig_old); ++ /* Lock before clone so that parent ++ * can set ptrace permissions prior ++ * to ListerThread actually executing ++ */ ++ if (sem_init(&lock, 0, 0) == 0) { + +- if (clone_pid >= 0) { +- int status, rc; +- while ((rc = sys0_waitpid(clone_pid, &status, __WALL)) < 0 && +- ERRNO == EINTR) { +- /* Keep waiting */ +- } +- if (rc < 0) { +- args.err = ERRNO; +- args.result = -1; +- } else if (WIFEXITED(status)) { +- switch (WEXITSTATUS(status)) { +- case 0: break; /* Normal process termination */ +- case 2: args.err = EFAULT; /* Some fault (e.g. SIGSEGV) detected */ +- args.result = -1; +- break; +- case 3: args.err = EPERM; /* Process is already being traced */ +- args.result = -1; +- break; +- default:args.err = ECHILD; /* Child died unexpectedly */ +- args.result = -1; +- break; ++ int clone_errno; ++ clone_pid = local_clone((int (*)(void *))ListerThread, &args); ++ clone_errno = errno; ++ ++ sys_sigprocmask(SIG_SETMASK, &sig_old, &sig_old); ++ ++ if (clone_pid >= 0) { ++ /* Allow child process to ptrace us ++ * and then release lock so that ++ * ListerThread then executes ++ */ ++ prctl(PR_SET_PTRACER, clone_pid, 0, 0, 0); ++ sem_post(&lock); ++ int status, rc; ++ while ((rc = sys0_waitpid(clone_pid, &status, __WALL)) < 0 && ++ ERRNO == EINTR) { ++ /* Keep waiting */ + } +- } else if (!WIFEXITED(status)) { +- args.err = EFAULT; /* Terminated due to an unhandled signal*/ ++ if (rc < 0) { ++ args.err = ERRNO; ++ args.result = -1; ++ } else if (WIFEXITED(status)) { ++ switch (WEXITSTATUS(status)) { ++ case 0: break; /* Normal process termination */ ++ case 2: args.err = EFAULT; /* Some fault (e.g. SIGSEGV) detected */ ++ args.result = -1; ++ break; ++ case 3: args.err = EPERM; /* Process is already being traced */ ++ args.result = -1; ++ break; ++ default:args.err = ECHILD; /* Child died unexpectedly */ ++ args.result = -1; ++ break; ++ } ++ } else if (!WIFEXITED(status)) { ++ args.err = EFAULT; /* Terminated due to an unhandled signal*/ ++ args.result = -1; ++ } ++ sem_destroy(&lock); ++ } else { + args.result = -1; ++ args.err = clone_errno; + } + } else { + args.result = -1; +- args.err = clone_errno; ++ args.err = errno; + } + } + only in patch2: unchanged: --- google-perftools-2.0.orig/debian/patches/20121206_syscall-support.patch +++ google-perftools-2.0/debian/patches/20121206_syscall-support.patch @@ -0,0 +1,39 @@ +Description: Fix FTBFS due to invalid type conversions +Origin: http://code.google.com/p/gperftools/source/detail?r=176 + +Index: src/base/linux_syscall_support.h +=================================================================== +--- src/base/linux_syscall_support.h (revision 175) ++++ src/base/linux_syscall_support.h (revision 176) +@@ -243,14 +243,13 @@ + long ru_nivcsw; + }; + +-struct siginfo; + #if defined(__i386__) || defined(__arm__) || defined(__PPC__) + + /* include/asm-{arm,i386,mips,ppc}/signal.h */ + struct kernel_old_sigaction { + union { + void (*sa_handler_)(int); +- void (*sa_sigaction_)(int, struct siginfo *, void *); ++ void (*sa_sigaction_)(int, siginfo_t *, void *); + }; + unsigned long sa_mask; + unsigned long sa_flags; +@@ -287,13 +286,13 @@ + unsigned long sa_flags; + union { + void (*sa_handler_)(int); +- void (*sa_sigaction_)(int, struct siginfo *, void *); ++ void (*sa_sigaction_)(int, siginfo_t *, void *); + }; + struct kernel_sigset_t sa_mask; + #else + union { + void (*sa_handler_)(int); +- void (*sa_sigaction_)(int, struct siginfo *, void *); ++ void (*sa_sigaction_)(int, siginfo_t *, void *); + }; + unsigned long sa_flags; + void (*sa_restorer)(void); only in patch2: unchanged: --- google-perftools-2.0.orig/debian/patches/20123107_fix_i386_frames.patch +++ google-perftools-2.0/debian/patches/20123107_fix_i386_frames.patch @@ -0,0 +1,28 @@ +Description: | + issue-385: updates to automake to pick up the explicit setting of the -fno-omit- + frame-pointer for i386 +Bug: http://code.google.com/p/gperftools/issues/detail?id=385 +Origin: http://code.google.com/p/gperftools/source/detail?r=151 + +Index: Makefile.am +=================================================================== +--- Makefile.am (revision 150) ++++ Makefile.am (revision 151) +@@ -72,6 +68,16 @@ + endif !ENABLE_FRAME_POINTERS + endif X86_64_AND_NO_FP_BY_DEFAULT + ++# As of gcc 4.6, -fomit-frame-pointer is the default even for i386. Since ++# we must always have frame pointers for i386 in order to generate backtraces ++# we now specify -fno-omit-frame-pointer by default (i386 only). ++if GCC ++if I386 ++AM_CXXFLAGS += -fno-omit-frame-pointer ++endif I386 ++endif GCC ++ ++ + # For windows systems (at least, mingw), we need to tell all our + # tests to link in libtcmalloc using -u. This is because libtcmalloc + # accomplishes its tasks via patching, leaving no work for the linker + only in patch2: unchanged: --- google-perftools-2.0.orig/debian/patches/20120725_heap-check-after-destructors.patch +++ google-perftools-2.0/debian/patches/20120725_heap-check-after-destructors.patch @@ -0,0 +1,20 @@ +Description: Always execute heap check after all destructors +Author: James Page <james.p...@ubuntu.com> +Forwarded: http://code.google.com/p/gperftools/issues/detail?id=437 + +Index: src/heap-checker.cc +=================================================================== +--- src/heap-checker.cc (revision 151) ++++ src/heap-checker.cc (working copy) +@@ -2025,9 +2025,9 @@ + // at the right time, on FreeBSD we always check after, even in the + // less strict modes. This just means FreeBSD is always a bit + // stricter in its checking than other OSes. +-#ifdef __FreeBSD__ ++ // This now appears to be the case in other OSes as well; ++ // so always check afterwards. + FLAGS_heap_check_after_destructors = true; +-#endif + + { SpinLockHolder l(&heap_checker_lock); + RAW_DCHECK(heap_checker_pid == getpid(), "");