From patchwork Fri Jul 15 19:56:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Eggert X-Patchwork-Id: 13814 Received: (qmail 59025 invoked by alias); 15 Jul 2016 19:57:00 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 59006 invoked by uid 89); 15 Jul 2016 19:56:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: zimbra.cs.ucla.edu Subject: Re: glibc 2.24 -- Release blockers To: Sinny Kumari References: <577EB298.4050903@linaro.org> <95e9ed04-a103-649c-8434-ac589a85a2c2@redhat.com> <578770A9.9070703@cs.ucla.edu> <08ec1982-7bc7-4c38-cf38-9849054748a8@redhat.com> <57883236.3050801@cs.ucla.edu> <5788E12C.9010205@cs.ucla.edu> Cc: Florian Weimer , Andreas Schwab , Adhemerval Zanella , GNU C Library From: Paul Eggert Message-ID: <57893FF7.30507@cs.ucla.edu> Date: Fri, 15 Jul 2016 21:56:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: On 07/15/2016 04:19 PM, Sinny Kumari wrote: > After applying this patch in emacs-25.0.95, it builds and run fine on ppc64(le), > Fedora rawhide. It no longer consumes memory in GB ! Thanks. Unfortunately the patch fails on other platforms, including Fedora 23 x86-64. So please try the attached, more-conservative patch instead. I have installed this into the Emacs master branch; it should also work in the emacs-25 branch, but I'd like further testing before I start advocating for that. From 2921f054ef3a2dca9a2cc48bbe956751a49b9d19 Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 @@ -233,7 +233,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 @@ -1643,15 +1643,17 @@ AC_DEFUN 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 ]], [[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 ]], + [[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 # Note that Solaris has sys/sysinfo.h which defines struct diff --git a/src/emacs.c b/src/emacs.c index bb85733..b221984 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -112,7 +112,7 @@ extern void moncontrol (int mode); #include #endif -#ifdef HAVE_PERSONALITY_LINUX32 +#ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE #include #endif @@ -796,24 +796,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) && !defined (CYGWIN) /* Extend the stack space available. Don't do that if dumping, -- 2.5.5