From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Errors building from master with a clean repository Date: Fri, 19 Apr 2019 18:05:35 -0700 Organization: UCLA Computer Science Department Message-ID: <7db3cae7-794c-83d6-b8f4-f0ec000d1674@cs.ucla.edu> References: <87ef5z9l23.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------BEFEA97A8438C6EFC4209A36" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="263877"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 Cc: emacs-devel@gnu.org To: Alex Gramiak Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 20 03:06:37 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hHeSi-0016P6-U6 for ged-emacs-devel@m.gmane.org; Sat, 20 Apr 2019 03:06:37 +0200 Original-Received: from localhost ([127.0.0.1]:35139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHeSh-0000Gs-U5 for ged-emacs-devel@m.gmane.org; Fri, 19 Apr 2019 21:06:35 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHeRt-0000FO-4o for emacs-devel@gnu.org; Fri, 19 Apr 2019 21:05:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHeRp-0008LK-Im for emacs-devel@gnu.org; Fri, 19 Apr 2019 21:05:45 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36172) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hHeRp-0008Iu-5n for emacs-devel@gnu.org; Fri, 19 Apr 2019 21:05:41 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A2D991616F9; Fri, 19 Apr 2019 18:05:39 -0700 (PDT) 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 fOB-JZKKFps9; Fri, 19 Apr 2019 18:05:35 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 946381617BE; Fri, 19 Apr 2019 18:05:35 -0700 (PDT) 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 38CW1O8waaEf; Fri, 19 Apr 2019 18:05:35 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 62E3B1616F9; Fri, 19 Apr 2019 18:05:35 -0700 (PDT) In-Reply-To: <87ef5z9l23.fsf@gmail.com> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x 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:235684 Archived-At: This is a multi-part message in MIME format. --------------BEFEA97A8438C6EFC4209A36 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit On 4/18/19 12:21 PM, Alex Gramiak wrote: > ./configure --enable-checking=all --enable-check-lisp-object-type \ > CFLAGS='-Og -gdwarf-4' --enable-checking=all hasn't worked for a while. Although your email prompted me to write and install patches to fix multiple bugs in this area, the remaining buggy suboptions --enablechecking=conslist and --enable-checking=xmallocoverrun are more trouble than they're worth to fix, and should go. (GCC's AddressSanitizer has made both options obsolete anyway.) Please try the two attached patches and then try the above 'configure' line again. Also, if you use older GCC or unusual GCC flags like '-Og' with --enable-gcc-warnings=warn-only (which is the default in developer builds), GCC will sometimes report false alarms. Typically I don't worry about these, as it's already plenty of work to pacify recent GCC with default options. A superficial look at the warnings you forwarded suggested that they're all false alarms. > GEN dmpstruct.h > -r: No such file or directory That one was my fault. Fixed in commits df5ca4f7e66fe075d1ad12a0e2831c4ed91fd186 and 856806d30fb16dbe695633a2dbe35a8fb4348998. --------------BEFEA97A8438C6EFC4209A36 Content-Type: text/x-patch; name="0001-Remove-enablechecking-conslist-configure-option.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Remove-enablechecking-conslist-configure-option.patch" >From 9280a1ce1cb2a086fbfa53390ff29eadd779d739 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 19 Apr 2019 17:37:35 -0700 Subject: [PATCH 1/2] Remove --enablechecking=conslist configure option * configure.ac: Remove the option. * configure.ac (ac_gc_check_cons_list, GC_CHECK_CONS_LIST): * src/alloc.c (check_cons_list) [GC_CHECK_CONS_LIST]: * src/lisp.h (lisp_h_check_cons_list, check_cons_list): Remove. All uses removed. * etc/NEWS: Mention this. --- configure.ac | 9 +-------- etc/NEWS | 5 +++++ src/alloc.c | 16 ---------------- src/eval.c | 9 --------- src/lisp.h | 11 ----------- 5 files changed, 6 insertions(+), 44 deletions(-) diff --git a/configure.ac b/configure.ac index 9d39bdd76b..b7bdce66ae 100644 --- a/configure.ac +++ b/configure.ac @@ -545,7 +545,7 @@ AC_DEFUN enable only specific categories of checks. Categories are: all,yes,no. Flags are: stringbytes, stringoverrun, stringfreelist, - structs, xmallocoverrun, conslist, glyphs])], + structs, xmallocoverrun, glyphs])], [ac_checking_flags="${enableval}"],[]) IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="$IFS," CHECK_STRUCTS=false @@ -560,7 +560,6 @@ AC_DEFUN ac_gc_check_string_overrun= ; ac_gc_check_string_free_list= ; ac_xmalloc_overrun= ; - ac_gc_check_cons_list= ; ac_glyphs_debug= ;; all) ac_enable_checking=1 ; CHECK_STRUCTS=true @@ -568,7 +567,6 @@ AC_DEFUN ac_gc_check_string_overrun=1 ; ac_gc_check_string_free_list=1 ; ac_xmalloc_overrun=1 ; - ac_gc_check_cons_list=1 ; ac_glyphs_debug=1 ;; # these enable particular checks stringbytes) ac_gc_check_stringbytes=1 ;; @@ -576,7 +574,6 @@ AC_DEFUN stringfreelist) ac_gc_check_string_free_list=1 ;; structs) CHECK_STRUCTS=true ;; xmallocoverrun) ac_xmalloc_overrun=1 ;; - conslist) ac_gc_check_cons_list=1 ;; glyphs) ac_glyphs_debug=1 ;; *) AC_MSG_ERROR(unknown check category $check) ;; esac @@ -614,10 +611,6 @@ AC_DEFUN AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1, [Define this to check for malloc buffer overrun.]) fi -if test x$ac_gc_check_cons_list != x ; then - AC_DEFINE(GC_CHECK_CONS_LIST, 1, -[Define this to check for errors in cons list.]) -fi if test x$ac_glyphs_debug != x ; then AC_DEFINE(GLYPH_DEBUG, 1, [Define this to enable glyphs debugging code.]) diff --git a/etc/NEWS b/etc/NEWS index 4d76143b13..f991dbaf97 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -89,6 +89,11 @@ Options" in the Emacs manual for more information. check that the portable dumper code has been updated to match the last change to one of the data structures that it relies on. ++++ +** The configure option '--enable-checking=conslist' has been withdrawn. +It made Emacs irredeemably slow, and is no longer useful with modern +debugging tools. + --- ** Emacs now requires GTK 2.24 and GTK 3.10 for the GTK 2 and GTK 3 builds respectively. diff --git a/src/alloc.c b/src/alloc.c index b5b6dc2f05..b51c205fa9 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -2831,18 +2831,6 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0, return val; } -#ifdef GC_CHECK_CONS_LIST -/* Get an error now if there's any junk in the cons free list. */ -void -check_cons_list (void) -{ - struct Lisp_Cons *tail = cons_free_list; - - while (tail) - tail = tail->u.s.u.chain; -} -#endif - /* Make a list of 1, 2, 3, 4 or 5 specified objects. */ Lisp_Object @@ -6033,8 +6021,6 @@ garbage_collect_1 (struct gcstat *gcst) /* Record this function, so it appears on the profiler's backtraces. */ record_in_backtrace (QAutomatic_GC, 0, 0); - check_cons_list (); - /* Don't keep undo information around forever. Do this early on, so it is no problem if the user quits. */ FOR_EACH_BUFFER (nextb) @@ -6154,8 +6140,6 @@ garbage_collect_1 (struct gcstat *gcst) unmark_main_thread (); - check_cons_list (); - gc_in_progress = 0; unblock_input (); diff --git a/src/eval.c b/src/eval.c index a636f6c50a..4693767ce7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2210,8 +2210,6 @@ eval_sub (Lisp_Object form) Lisp_Object args_left = original_args; ptrdiff_t numargs = list_length (args_left); - check_cons_list (); - if (numargs < XSUBR (fun)->min_args || (XSUBR (fun)->max_args >= 0 && XSUBR (fun)->max_args < numargs)) @@ -2240,7 +2238,6 @@ eval_sub (Lisp_Object form) val = XSUBR (fun)->function.aMANY (argnum, vals); - check_cons_list (); lisp_eval_depth--; /* Do the debug-on-exit now, while VALS still exists. */ if (backtrace_debug_on_exit (specpdl + count)) @@ -2346,7 +2343,6 @@ eval_sub (Lisp_Object form) else xsignal1 (Qinvalid_function, original_fun); } - check_cons_list (); lisp_eval_depth--; if (backtrace_debug_on_exit (specpdl + count)) @@ -2786,8 +2782,6 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) if (debug_on_next_call) do_debug_on_call (Qlambda, count); - check_cons_list (); - original_fun = args[0]; retry: @@ -2817,13 +2811,11 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */) else if (EQ (funcar, Qautoload)) { Fautoload_do_load (fun, original_fun, Qnil); - check_cons_list (); goto retry; } else xsignal1 (Qinvalid_function, original_fun); } - check_cons_list (); lisp_eval_depth--; if (backtrace_debug_on_exit (specpdl + count)) val = call_debugger (list2 (Qexit, val)); @@ -2935,7 +2927,6 @@ apply_lambda (Lisp_Object fun, Lisp_Object args, ptrdiff_t count) set_backtrace_args (specpdl + count, arg_vector, numargs); tem = funcall_lambda (fun, numargs, arg_vector); - check_cons_list (); lisp_eval_depth--; /* Do the debug-on-exit now, while arg_vector still exists. */ if (backtrace_debug_on_exit (specpdl + count)) diff --git a/src/lisp.h b/src/lisp.h index c2cb89de9d..3377ea3807 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -413,9 +413,6 @@ typedef EMACS_INT Lisp_Word; #define lisp_h_XCONS(a) \ (eassert (CONSP (a)), XUNTAG (a, Lisp_Cons, struct Lisp_Cons)) #define lisp_h_XHASH(a) XUFIXNUM (a) -#ifndef GC_CHECK_CONS_LIST -# define lisp_h_check_cons_list() ((void) 0) -#endif #if USE_LSB_TAG # define lisp_h_make_fixnum(n) \ XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0)) @@ -472,9 +469,6 @@ typedef EMACS_INT Lisp_Word; # define XCDR(c) lisp_h_XCDR (c) # define XCONS(a) lisp_h_XCONS (a) # define XHASH(a) lisp_h_XHASH (a) -# ifndef GC_CHECK_CONS_LIST -# define check_cons_list() lisp_h_check_cons_list () -# endif # if USE_LSB_TAG # define make_fixnum(n) lisp_h_make_fixnum (n) # define XFIXNAT(a) lisp_h_XFIXNAT (a) @@ -3983,11 +3977,6 @@ extern void init_alloc (void); extern void syms_of_alloc (void); extern struct buffer * allocate_buffer (void); extern int valid_lisp_object_p (Lisp_Object); -#ifdef GC_CHECK_CONS_LIST -extern void check_cons_list (void); -#else -INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); } -#endif /* Defined in gmalloc.c. */ #if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC -- 2.20.1 --------------BEFEA97A8438C6EFC4209A36 Content-Type: text/x-patch; name="0002-Remove-enable-checking-xmallocoverrun.patch" Content-Disposition: attachment; filename="0002-Remove-enable-checking-xmallocoverrun.patch" Content-Transfer-Encoding: quoted-printable >From f80a8246bef0e3aa756282625fe69ac69dd0c177 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 19 Apr 2019 17:37:35 -0700 Subject: [PATCH 2/2] Remove --enable-checking=3Dxmallocoverrun MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit It doesn=E2=80=99t work anymore, and these days =E2=80=98gcc -fsanitize=3D= address=E2=80=99 does a better job anyway. * configure.ac: Remove the option. * configure.ac (ac_xmalloc_overrun, XMALLOC_OVERRUN_CHECK): * src/alloc.c (XMALLOC_OVERRUN_CHECK_OVERHEAD) (XMALLOC_OVERRUN_CHECK_SIZE, XMALLOC_OVERRUN_SIZE_SIZE) (xmalloc_overrun_check_header, xmalloc_overrun_check_trailer) (xmalloc_put_size, xmalloc_get_size, overrun_check_malloc) (overrun_check_realloc, overrun_check_free): Remove. All uses removed. * etc/NEWS: Mention this. --- configure.ac | 9 +-- etc/NEWS | 7 ++- src/alloc.c | 169 +-------------------------------------------------- 3 files changed, 6 insertions(+), 179 deletions(-) diff --git a/configure.ac b/configure.ac index b7bdce66ae..32b8ce5019 100644 --- a/configure.ac +++ b/configure.ac @@ -545,7 +545,7 @@ AC_DEFUN enable only specific categories of checks. Categories are: all,yes,no. Flags are: stringbytes, stringoverrun, stringfreelist, - structs, xmallocoverrun, glyphs])], + structs, glyphs])], [ac_checking_flags=3D"${enableval}"],[]) IFS=3D"${IFS=3D }"; ac_save_IFS=3D"$IFS"; IFS=3D"$IFS," CHECK_STRUCTS=3Dfalse @@ -559,21 +559,18 @@ AC_DEFUN ac_gc_check_stringbytes=3D ; ac_gc_check_string_overrun=3D ; ac_gc_check_string_free_list=3D ; - ac_xmalloc_overrun=3D ; ac_glyphs_debug=3D ;; all) ac_enable_checking=3D1 ; CHECK_STRUCTS=3Dtrue ac_gc_check_stringbytes=3D1 ; ac_gc_check_string_overrun=3D1 ; ac_gc_check_string_free_list=3D1 ; - ac_xmalloc_overrun=3D1 ; ac_glyphs_debug=3D1 ;; # these enable particular checks stringbytes) ac_gc_check_stringbytes=3D1 ;; stringoverrun) ac_gc_check_string_overrun=3D1 ;; stringfreelist) ac_gc_check_string_free_list=3D1 ;; structs) CHECK_STRUCTS=3Dtrue ;; - xmallocoverrun) ac_xmalloc_overrun=3D1 ;; glyphs) ac_glyphs_debug=3D1 ;; *) AC_MSG_ERROR(unknown check category $check) ;; esac @@ -607,10 +604,6 @@ AC_DEFUN AC_DEFINE(GC_CHECK_STRING_FREE_LIST, 1, [Define this to check the string free list.]) fi -if test x$ac_xmalloc_overrun !=3D x ; then - AC_DEFINE(XMALLOC_OVERRUN_CHECK, 1, -[Define this to check for malloc buffer overrun.]) -fi if test x$ac_glyphs_debug !=3D x ; then AC_DEFINE(GLYPH_DEBUG, 1, [Define this to enable glyphs debugging code.]) diff --git a/etc/NEWS b/etc/NEWS index f991dbaf97..051063171e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -90,9 +90,10 @@ check that the portable dumper code has been updated t= o match the last change to one of the data structures that it relies on. =20 +++ -** The configure option '--enable-checking=3Dconslist' has been withdraw= n. -It made Emacs irredeemably slow, and is no longer useful with modern -debugging tools. +** The configure options '--enable-checking=3Dconslist' and +'--enable-checking=3Dxmallocoverrun' have been withdrawn. The former +made Emacs irredeemably slow, and the latter made it crash. Neither +option was useful with modern debugging tools. =20 --- ** Emacs now requires GTK 2.24 and GTK 3.10 for the GTK 2 and GTK 3 diff --git a/src/alloc.c b/src/alloc.c index b51c205fa9..35751faed8 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -151,9 +151,7 @@ malloc_initialize_hook (void) =20 if (malloc_set_state (malloc_state_ptr) !=3D 0) emacs_abort (); -# ifndef XMALLOC_OVERRUN_CHECK alloc_unexec_post (); -# endif } } =20 @@ -681,171 +679,6 @@ verify (LISP_ALIGNMENT % GCALIGNMENT =3D=3D 0); it never does anything that requires an alignment of 16. */ enum { MALLOC_IS_LISP_ALIGNED =3D alignof (max_align_t) % LISP_ALIGNMENT= =3D=3D 0 }; =20 -#ifndef XMALLOC_OVERRUN_CHECK -#define XMALLOC_OVERRUN_CHECK_OVERHEAD 0 -#else - -/* Check for overrun in malloc'ed buffers by wrapping a header and trail= er - around each block. - - The header consists of XMALLOC_OVERRUN_CHECK_SIZE fixed bytes - followed by XMALLOC_OVERRUN_SIZE_SIZE bytes containing the original - block size in little-endian order. The trailer consists of - XMALLOC_OVERRUN_CHECK_SIZE fixed bytes. - - The header is used to detect whether this block has been allocated - through these functions, as some low-level libc functions may - bypass the malloc hooks. */ - -#define XMALLOC_OVERRUN_CHECK_SIZE 16 -#define XMALLOC_OVERRUN_CHECK_OVERHEAD \ - (2 * XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE) - -/* Define XMALLOC_OVERRUN_SIZE_SIZE so that (1) it's large enough to - hold a size_t value and (2) the header size is a multiple of the - alignment that Emacs needs for C types and for USE_LSB_TAG. */ -#define XMALLOC_OVERRUN_SIZE_SIZE \ - (((XMALLOC_OVERRUN_CHECK_SIZE + sizeof (size_t) \ - + LISP_ALIGNMENT - 1) \ - / LISP_ALIGNMENT * LISP_ALIGNMENT) \ - - XMALLOC_OVERRUN_CHECK_SIZE) - -static char const xmalloc_overrun_check_header[XMALLOC_OVERRUN_CHECK_SIZ= E] =3D - { '\x9a', '\x9b', '\xae', '\xaf', - '\xbf', '\xbe', '\xce', '\xcf', - '\xea', '\xeb', '\xec', '\xed', - '\xdf', '\xde', '\x9c', '\x9d' }; - -static char const xmalloc_overrun_check_trailer[XMALLOC_OVERRUN_CHECK_SI= ZE] =3D - { '\xaa', '\xab', '\xac', '\xad', - '\xba', '\xbb', '\xbc', '\xbd', - '\xca', '\xcb', '\xcc', '\xcd', - '\xda', '\xdb', '\xdc', '\xdd' }; - -/* Insert and extract the block size in the header. */ - -static void -xmalloc_put_size (unsigned char *ptr, size_t size) -{ - int i; - for (i =3D 0; i < XMALLOC_OVERRUN_SIZE_SIZE; i++) - { - *--ptr =3D size & ((1 << CHAR_BIT) - 1); - size >>=3D CHAR_BIT; - } -} - -static size_t -xmalloc_get_size (unsigned char *ptr) -{ - size_t size =3D 0; - int i; - ptr -=3D XMALLOC_OVERRUN_SIZE_SIZE; - for (i =3D 0; i < XMALLOC_OVERRUN_SIZE_SIZE; i++) - { - size <<=3D CHAR_BIT; - size +=3D *ptr++; - } - return size; -} - - -/* Like malloc, but wraps allocated block with header and trailer. */ - -static void * -overrun_check_malloc (size_t size) -{ - register unsigned char *val; - if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size) - emacs_abort (); - - val =3D malloc (size + XMALLOC_OVERRUN_CHECK_OVERHEAD); - if (val) - { - memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_S= IZE); - val +=3D XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; - xmalloc_put_size (val, size); - memcpy (val + size, xmalloc_overrun_check_trailer, - XMALLOC_OVERRUN_CHECK_SIZE); - } - return val; -} - - -/* Like realloc, but checks old block for overrun, and wraps new block - with header and trailer. */ - -static void * -overrun_check_realloc (void *block, size_t size) -{ - register unsigned char *val =3D (unsigned char *) block; - if (SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD < size) - emacs_abort (); - - if (val - && memcmp (xmalloc_overrun_check_header, - val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE, - XMALLOC_OVERRUN_CHECK_SIZE) =3D=3D 0) - { - size_t osize =3D xmalloc_get_size (val); - if (memcmp (xmalloc_overrun_check_trailer, val + osize, - XMALLOC_OVERRUN_CHECK_SIZE)) - emacs_abort (); - memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); - val -=3D XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; - memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_= SIZE); - } - - val =3D realloc (val, size + XMALLOC_OVERRUN_CHECK_OVERHEAD); - - if (val) - { - memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_S= IZE); - val +=3D XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; - xmalloc_put_size (val, size); - memcpy (val + size, xmalloc_overrun_check_trailer, - XMALLOC_OVERRUN_CHECK_SIZE); - } - return val; -} - -/* Like free, but checks block for overrun. */ - -static void -overrun_check_free (void *block) -{ - unsigned char *val =3D (unsigned char *) block; - - if (val - && memcmp (xmalloc_overrun_check_header, - val - XMALLOC_OVERRUN_CHECK_SIZE - XMALLOC_OVERRUN_SIZE_SIZE, - XMALLOC_OVERRUN_CHECK_SIZE) =3D=3D 0) - { - size_t osize =3D xmalloc_get_size (val); - if (memcmp (xmalloc_overrun_check_trailer, val + osize, - XMALLOC_OVERRUN_CHECK_SIZE)) - emacs_abort (); -#ifdef XMALLOC_CLEAR_FREE_MEMORY - val -=3D XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; - memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_OVERHEAD); -#else - memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE); - val -=3D XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_SIZE; - memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE + XMALLOC_OVERRUN_SIZE_= SIZE); -#endif - } - - free (val); -} - -#undef malloc -#undef realloc -#undef free -#define malloc overrun_check_malloc -#define realloc overrun_check_realloc -#define free overrun_check_free -#endif - /* If compiled with XMALLOC_BLOCK_INPUT_CHECK, define a symbol BLOCK_INPUT_IN_MEMORY_ALLOCATORS that is visible to the debugger. If that variable is set, block input while in one of Emacs's memory @@ -1820,7 +1653,7 @@ static char const string_overrun_cookie[GC_STRING_O= VERRUN_COOKIE_SIZE] =3D calculating a value to be passed to malloc. */ static ptrdiff_t const STRING_BYTES_MAX =3D min (STRING_BYTES_BOUND, - ((SIZE_MAX - XMALLOC_OVERRUN_CHECK_OVERHEAD + ((SIZE_MAX - GC_STRING_EXTRA - offsetof (struct sblock, data) - SDATA_DATA_OFFSET) --=20 2.20.1 --------------BEFEA97A8438C6EFC4209A36--