Package: emacs24 Version: 24.5+1-6+b2 Severity: important Tags: patch upstream
Dear Maintainer, glibc 2.24 has removed the possibility to add malloc hooks, as they have been deprecated for more that 5 years. When emacs is built against this glibc will switch to its internal malloc implementation. Unfortunately it hasn't been widely tested and is currently broken in the following ways: - When src/gmalloc.c is compiled with gcc-5 or gcc-6, it leads to infinite recursion. - On 64-bit systems with aggressive ASLR (such as ppc64), the emacs internal malloc needs a lot of memory (typically 12 GiB). Both issues have already been fixed upstream. You will find attached the corresponding patches backported for 2.24. Note that while the malloc hooks support have been removed from the public interfaces, they are still available in the library. Therefore existing binaries will keep working. Also note that the emacs-25 already contains both fixes. Could you please do an upload with the two attached patches? glibc 2.24 is already available in experimental and will plan to upload it to sid in the next days/weeks. Thanks, Aurelien -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.6.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages emacs24 depends on: ii emacs24-bin-common 24.5+1-6+b2 ii gconf-service 3.2.6-3 ii libacl1 2.2.52-3 ii libasound2 1.1.1-2 ii libatk1.0-0 2.20.0-1 ii libc6 2.24-0experimental0 ii libcairo-gobject2 1.14.6-1+b1 ii libcairo2 1.14.6-1+b1 ii libdbus-1-3 1.10.8-1 ii libfontconfig1 2.11.0-6.4 ii libfreetype6 2.6.3-3+b1 ii libgconf-2-4 3.2.6-3 ii libgdk-pixbuf2.0-0 2.34.0-1 ii libgif7 5.1.4-0.3 ii libglib2.0-0 2.48.1-2 ii libgnutls30 3.5.2-2 ii libgomp1 6.1.1-10 ii libgpm2 1.20.4-6.2 ii libgtk-3-0 3.20.6-2 ii libice6 2:1.0.9-1+b1 ii libjpeg62-turbo 1:1.5.0-1 ii libm17n-0 1.7.0-3+b1 ii libmagickcore-6.q16-2 8:6.8.9.9-7.2 ii libmagickwand-6.q16-2 8:6.8.9.9-7.2 ii libotf0 0.9.13-3 ii libpango-1.0-0 1.40.1-1 ii libpangocairo-1.0-0 1.40.1-1 ii libpng16-16 1.6.23-1 ii librsvg2-2 2.40.16-1 ii libselinux1 2.5-3 ii libsm6 2:1.2.2-1+b1 ii libtiff5 4.0.6-2 ii libtinfo5 6.0+20160625-1 ii libx11-6 2:1.6.3-1 ii libxft2 2.3.2-1 ii libxinerama1 2:1.1.3-1+b1 ii libxml2 2.9.4+dfsg1-1 ii libxpm4 1:3.5.11-1+b1 ii libxrandr2 2:1.5.0-1 ii libxrender1 1:0.9.9-2 ii zlib1g 1:1.2.8.dfsg-2+b1 emacs24 recommends no packages. Versions of packages emacs24 suggests: pn emacs24-common-non-dfsg <none> -- no debconf information
>From 4b1436b702d56eedd27a0777fc7232cdfb7ac4f6 Mon Sep 17 00:00:00 2001 From: Wolfgang Jenkner <wjenk...@inode.at> Date: Sat, 26 Dec 2015 12:12:02 -0800 Subject: [PATCH] Always define gmalloc etc. in src/gmalloc.c This is a work-around to prevent the compiler from using semantic knowledge about malloc for optimization purposes. E.g., gcc 5.2 with -O2 replaces most of calloc's definition by a call to calloc; see Bug#22085. * src/gmalloc.c [!HYBRID_MALLOC] (malloc, realloc, calloc) (aligned_alloc, free): Do not undef. Instead, define these as functions (perhaps renamed to gmalloc etc.) in terms of gmalloc etc. --- src/gmalloc.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/gmalloc.c b/src/gmalloc.c index a88f4ab..90a52a1 100644 --- a/src/gmalloc.c +++ b/src/gmalloc.c @@ -49,6 +49,17 @@ extern "C" #include <stddef.h> +#undef malloc +#undef realloc +#undef calloc +#undef aligned_alloc +#undef free +#define malloc gmalloc +#define realloc grealloc +#define calloc gcalloc +#define aligned_alloc galigned_alloc +#define free gfree +#define malloc_info gmalloc_info /* Allocate SIZE bytes of memory. */ extern void *malloc (size_t size); @@ -1747,6 +1758,42 @@ valloc (size_t size) return aligned_alloc (pagesize, size); } +#undef malloc +#undef realloc +#undef calloc +#undef aligned_alloc +#undef free + +void * +malloc (size_t size) +{ + return gmalloc (size); +} + +void * +calloc (size_t nmemb, size_t size) +{ + return gcalloc (nmemb, size); +} + +void +free (void *ptr) +{ + gfree (ptr); +} + +void * +aligned_alloc (size_t alignment, size_t size) +{ + return galigned_alloc (alignment, size); +} + +void * +realloc (void *ptr, size_t size) +{ + return grealloc (ptr, size); +} + #ifdef GC_MCHECK /* Standard debugging hooks for `malloc'. -- 2.8.1
>From e95b023163e96538b15f030b7176b7ec59cf86f5 Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Fri, 15 Jul 2016 13:07:09 +0200 Subject: [PATCH] Port to glibc 2.24 (pre-release) + ppc64 Inspired by a suggestion by Florian Weimer in: https://sourceware.org/ml/libc-alpha/2016-07/msg00425.html * configure.ac (HAVE_PERSONALITY_ADDR_NO_RANDOMIZE): Rename from HAVE_PERSONALITY_LINUX32, and check for ADDR_NO_RANDOMIZE (the crucial thing) instead of for LINUX32. All uses changed. * src/emacs.c (main) [HAVE_PERSONALITY_ADDR_NO_RANDOMIZE]: Use ADDR_NO_RANDOMIZE from personality.h rather than inventing the flag ourselves. Just set that flag, rather than also setting the persona. When doing it, avoid functions like putenv that may allocate memory. --- admin/CPP-DEFINES | 2 +- configure.ac | 20 +++++++++++--------- src/emacs.c | 30 ++++++++++++++---------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index c7ec8ce..5e6146b 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES @@ -244,7 +244,7 @@ HAVE_NET_IF_DL_H HAVE_NET_IF_H HAVE_NLIST_H HAVE_OTF_GET_VARIATION_GLYPHS -HAVE_PERSONALITY_LINUX32 +HAVE_PERSONALITY_ADDR_NO_RANDOMIZE HAVE_PNG HAVE_PNG_H HAVE_POSIX_MEMALIGN diff --git a/configure.ac b/configure.ac index dd1af5b..c94ecb6 100644 --- a/configure.ac +++ b/configure.ac @@ -1478,15 +1478,17 @@ AC_CHECK_HEADERS_ONCE( sys/resource.h sys/utsname.h pwd.h utmp.h util.h) -AC_MSG_CHECKING(if personality LINUX32 can be set) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/personality.h>]], [[personality (PER_LINUX32)]])], - emacs_cv_personality_linux32=yes, - emacs_cv_personality_linux32=no) -AC_MSG_RESULT($emacs_cv_personality_linux32) - -if test $emacs_cv_personality_linux32 = yes; then - AC_DEFINE(HAVE_PERSONALITY_LINUX32, 1, - [Define to 1 if personality LINUX32 can be set.]) +AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE], + [emacs_cv_personality_addr_no_randomize], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <sys/personality.h>]], + [[personality (personality (0xffffffff) + | ADDR_NO_RANDOMIZE)]])], + [emacs_cv_personality_addr_no_randomize=yes], + [emacs_cv_personality_addr_no_randomize=no])]) +if test $emacs_cv_personality_addr_no_randomize = yes; then + AC_DEFINE([HAVE_PERSONALITY_ADDR_NO_RANDOMIZE], [1], + [Define to 1 if personality flag ADDR_NO_RANDOMIZE exists.]) fi dnl On Solaris 8 there's a compilation warning for term.h because diff --git a/src/emacs.c b/src/emacs.c index bb85733..b221984 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -99,7 +99,7 @@ extern void moncontrol (int mode); #include <sys/resource.h> #endif -#ifdef HAVE_PERSONALITY_LINUX32 +#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE #include <sys/personality.h> #endif @@ -833,24 +833,22 @@ main (int argc, char **argv) dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0 || strcmp (argv[argc - 1], "bootstrap") == 0); -#ifdef HAVE_PERSONALITY_LINUX32 - if (dumping && ! getenv ("EMACS_HEAP_EXEC")) +#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE + if (dumping) { - /* Set this so we only do this once. */ - xputenv ("EMACS_HEAP_EXEC=true"); - - /* A flag to turn off address randomization which is introduced - in linux kernel shipped with fedora core 4 */ -#define ADD_NO_RANDOMIZE 0x0040000 - personality (PER_LINUX32 | ADD_NO_RANDOMIZE); -#undef ADD_NO_RANDOMIZE - - execvp (argv[0], argv); + int pers = personality (0xffffffff); + if (! (pers & ADDR_NO_RANDOMIZE) + && 0 <= personality (pers | ADDR_NO_RANDOMIZE)) + { + /* Address randomization was enabled, but is now disabled. + Re-execute Emacs to get a clean slate. */ + execvp (argv[0], argv); - /* If the exec fails, try to dump anyway. */ - emacs_perror (argv[0]); + /* If the exec fails, warn and then try without a clean slate. */ + perror (argv[0]); + } } -#endif /* HAVE_PERSONALITY_LINUX32 */ +#endif #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK) /* Extend the stack space available. -- 2.8.1