From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: hybrid_malloc on CANNOT_DUMP? Date: Sun, 20 Nov 2016 17:03:30 -0800 Organization: UCLA Computer Science Department Message-ID: <92f6cd2e-5141-6e60-df08-4a33269928cd@cs.ucla.edu> References: <337f0a16-afbb-63dc-0d24-d53a9986be31@dancol.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------E8AF1C7A8397B83A93E956FD" X-Trace: blaine.gmane.org 1479690272 24216 195.159.176.226 (21 Nov 2016 01:04:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 21 Nov 2016 01:04:32 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 To: Daniel Colascione , Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 21 02:04:25 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c8d1v-0004HP-Ul for ged-emacs-devel@m.gmane.org; Mon, 21 Nov 2016 02:04:20 +0100 Original-Received: from localhost ([::1]:46774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8d1x-0004uv-RW for ged-emacs-devel@m.gmane.org; Sun, 20 Nov 2016 20:04:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8d1J-0004uT-4Z for emacs-devel@gnu.org; Sun, 20 Nov 2016 20:03:42 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8d1E-0006BP-GQ for emacs-devel@gnu.org; Sun, 20 Nov 2016 20:03:41 -0500 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33314) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c8d1E-0006B3-6m for emacs-devel@gnu.org; Sun, 20 Nov 2016 20:03:36 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9CA2216009D; Sun, 20 Nov 2016 17:03:34 -0800 (PST) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id mFJLGSFcdInV; Sun, 20 Nov 2016 17:03:31 -0800 (PST) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id F00951600A0; Sun, 20 Nov 2016 17:03:30 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Tm1mJLwew4fh; Sun, 20 Nov 2016 17:03:30 -0800 (PST) Original-Received: from [192.168.1.9] (unknown [47.153.178.162]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BF03C16009D; Sun, 20 Nov 2016 17:03:30 -0800 (PST) In-Reply-To: <337f0a16-afbb-63dc-0d24-d53a9986be31@dancol.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:209516 Archived-At: This is a multi-part message in MIME format. --------------E8AF1C7A8397B83A93E956FD Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Daniel Colascione wrote: > Emacs on GNU/Linux and X11 crashes on startup in a CANNOT_DUMP configur= ation due > to some nonsense inside gmalloc. Why wouldn't we want to force hybrid_m= alloc=3Doff > in a CANNOT_DUMP configuration? Yes, that makes sense. More generally, the CANNOT_DUMP code has been suff= ering=20 from bitrot for some time. I just now made a pass through it to fix some = gotchas=20 and installed the attached into Emacs master. It's still a mess, but at l= east I=20 can now do 'configure CANNOT_DUMP=3Dyes emacs_cv_var_doug_lea_malloc=3Dno= ' and run=20 'make check', and most tests pass. Hope this helps. Can we hope that you're working on supporting a fast CANNOT_DUMP implemen= tation?=20 That'd be nice.... --------------E8AF1C7A8397B83A93E956FD Content-Type: text/x-diff; name="0001-Make-CANNOT_DUMP-work-better-on-GNU-Linux.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Make-CANNOT_DUMP-work-better-on-GNU-Linux.patch" =46rom 8c95deec6b3d7ff5f0b295c3948a1e0fce7ba726 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 20 Nov 2016 16:57:17 -0800 Subject: [PATCH] Make CANNOT_DUMP work better on GNU/Linux Clean up some of the bitrot affecting the CANNOT_DUMP code. This lets the build succeed again, and fixes the testing framework so that most test cases now pass. About twenty test cases still fail, though, and we still have Bug#24974. * configure.ac (CANNOT_DUMP): Now empty if CANNOT_DUMP. (SYSTEM_MALLOC): Now true if CANNOT_DUMP. There should no longer be any point to messing with a private memory allocator unless Emacs is dumping. * src/alloc.c (alloc_unexec_pre, alloc_unexec_post, check_pure_size): * src/image.c (reset_image_types): * src/lastfile.c (my_endbss, _my_endbss, my_endbss_static): Do not define if CANNOT_DUMP. * src/emacs.c (might_dump) [CANNOT_DUMP]: Now always false and local. (daemon_pipe) [!WINDOWSNT]: Now static. * test/Makefile.in (mostlyclean): Remove *.tmp files. (make-test-deps.mk): Elide CANNOT_DUMP chatter. --- configure.ac | 2 ++ src/alloc.c | 22 ++++++++++++++-------- src/emacs.c | 10 +++++++--- src/image.c | 3 +++ src/lastfile.c | 4 ++++ test/Makefile.in | 7 +++++-- 6 files changed, 35 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index c9759e1..2d116de 100644 --- a/configure.ac +++ b/configure.ac @@ -1366,6 +1366,7 @@ AC_DEFUN UNEXEC_OBJ=3Dunexsol.o ;; esac +test "$CANNOT_DUMP" =3D "yes" && UNEXEC_OBJ=3D =20 LD_SWITCH_SYSTEM=3D case "$opsys" in @@ -2154,6 +2155,7 @@ AC_DEFUN hybrid_malloc=3D system_malloc=3Dyes =20 +test "$CANNOT_DUMP" =3D yes || case "$opsys" in ## darwin ld insists on the use of malloc routines in the System frame= work. darwin | mingw32 | nacl | sol2-10) ;; diff --git a/src/alloc.c b/src/alloc.c index 90c6f94..175dcab 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -173,31 +173,34 @@ voidfuncptr __MALLOC_HOOK_VOLATILE __malloc_initial= ize_hook EXTERNALLY_VISIBLE =20 #endif =20 +#if defined DOUG_LEA_MALLOC || !defined CANNOT_DUMP + /* Allocator-related actions to do just before and after unexec. */ =20 void alloc_unexec_pre (void) { -#ifdef DOUG_LEA_MALLOC +# ifdef DOUG_LEA_MALLOC malloc_state_ptr =3D malloc_get_state (); if (!malloc_state_ptr) fatal ("malloc_get_state: %s", strerror (errno)); -#endif -#ifdef HYBRID_MALLOC +# endif +# ifdef HYBRID_MALLOC bss_sbrk_did_unexec =3D true; -#endif +# endif } =20 void alloc_unexec_post (void) { -#ifdef DOUG_LEA_MALLOC +# ifdef DOUG_LEA_MALLOC free (malloc_state_ptr); -#endif -#ifdef HYBRID_MALLOC +# endif +# ifdef HYBRID_MALLOC bss_sbrk_did_unexec =3D false; -#endif +# endif } +#endif =20 /* Mark, unmark, query mark bit of a Lisp string. S must be a pointer to a struct Lisp_String. */ @@ -5216,6 +5219,8 @@ pure_alloc (size_t size, int type) } =20 =20 +#ifndef CANNOT_DUMP + /* Print a warning if PURESIZE is too small. */ =20 void @@ -5226,6 +5231,7 @@ check_pure_size (void) " bytes needed)"), pure_bytes_used + pure_bytes_used_before_overflow); } +#endif =20 =20 /* Find the byte sequence {DATA[0], ..., DATA[NBYTES-1], '\0'} from diff --git a/src/emacs.c b/src/emacs.c index efd4fa3..ac9b649 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -130,11 +130,15 @@ Lisp_Object Vlibrary_cache; on subsequent starts. */ bool initialized; =20 +#ifdef CANNOT_DUMP +enum { might_dump =3D false }; +#else /* Set to true if this instance of Emacs might dump. */ -#ifndef DOUG_LEA_MALLOC +# ifndef DOUG_LEA_MALLOC static -#endif +# endif bool might_dump; +#endif =20 #ifdef DARWIN_OS extern void unexec_init_emacs_zone (void); @@ -196,7 +200,7 @@ int daemon_type; #ifndef WINDOWSNT /* Pipe used to send exit notification to the background daemon parent a= t startup. On Windows, we use a kernel event instead. */ -int daemon_pipe[2]; +static int daemon_pipe[2]; #else HANDLE w32_daemon_event; #endif diff --git a/src/image.c b/src/image.c index d82fedb..5614f39 100644 --- a/src/image.c +++ b/src/image.c @@ -9776,6 +9776,8 @@ lookup_image_type (Lisp_Object type) return NULL; } =20 +#if !defined CANNOT_DUMP && defined HAVE_WINDOW_SYSTEM + /* Reset image_types before dumping. Called from Fdump_emacs. */ =20 @@ -9789,6 +9791,7 @@ reset_image_types (void) image_types =3D next; } } +#endif =20 void syms_of_image (void) diff --git a/src/lastfile.c b/src/lastfile.c index 9d70b00..27602bd 100644 --- a/src/lastfile.c +++ b/src/lastfile.c @@ -43,6 +43,8 @@ along with GNU Emacs. If not, see . */ char my_edata[] =3D "End of Emacs initialized data"; #endif =20 +#ifndef CANNOT_DUMP + /* Help unexec locate the end of the .bss area used by Emacs (which isn't always a separate section in NT executables). */ char my_endbss[1]; @@ -52,3 +54,5 @@ char my_endbss[1]; of the bss area used by Emacs. */ static char _my_endbss[1]; char * my_endbss_static =3D _my_endbss; + +#endif diff --git a/test/Makefile.in b/test/Makefile.in index 33e625f..f2f2763 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -190,6 +190,7 @@ .PHONY: =20 mostlyclean: -@for f in ${LOGFILES}; do test ! -f $$f || mv $$f $$f~; done + rm -f *.tmp =20 clean: -rm -f ${LOGFILES} ${LOGSAVEFILES} @@ -206,5 +207,7 @@ maintainer-clean: make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \ --eval "(make-test-deps \"$(srcdir)\")" \ - 2> $@ -# Makefile ends here. + 2> $@.tmp + # Hack to elide any CANNOT_DUMP=3Dyes chatter. + sed '/\.log: /!d' $@.tmp >$@ + rm -f $@.tmp --=20 2.7.4 --------------E8AF1C7A8397B83A93E956FD--