develooper Front page | perl.perl5.porters | Postings from June 2003

Re: your malloc patches

Thread Previous | Thread Next
From:
Ilya Zakharevich
Date:
June 20, 2003 02:47
Subject:
Re: your malloc patches
Message ID:
20030620094737.GA802@math.berkeley.edu
On Fri, Jun 20, 2003 at 12:20:31PM +0300, Jarkko Hietaniemi wrote:
> A propos, I looked closer into the assertion failure in Tru64, and
> it's the two calls to FILLCHECK_DEADBEEF() that are failing.  If I
> #if 0 them, Perl builds and tests okay in Tru64.

So if you disable bug-detection feature, things work.  ;-) So add
-DNO_FILL_CHECK as a temporary measure.  Actually, apply the patch
below, and -DFILL_CHECK_DEFAULT=0 (so that this may be changed at
runtime).

Anyway, I was wrong that I can't do better with detection of
write-to-free()ed-or-not-yet-malloc()ed region (this is what happens
above).  But before I do this (some work required), could somebody
check what is the contents of memory when FILLCHECK_DEADBEEF() fails?

Thanks,
Ilya

P.S.  I find the message written by malloc.c:botch() misleading.  It is done by

  #define	ASSERT(p,diag)   if (!(p)) botch(diag,STRINGIFY(p));  else

and STRINGIFY() expands p - and with the current state of things the
expansion may take hundreds of bytes; I do not remember cpp magic well
enough: is it possible to do STRINGIFY_UNEXPANDED() in cpp?

--- ./malloc.c-ppre	Fri Jun 20 11:43:27 2003
+++ ./malloc.c	Fri Jun 20 11:46:09 2003
@@ -1033,6 +1033,16 @@ extern	Malloc_t sbrk(int);
 #ifndef NO_MALLOC_DYNAMIC_CFG
 #  define PERL_MALLOC_OPT_CHARS "FMfAPGdac"
 
+#  ifndef FILL_DEAD_DEFAULT
+#    define FILL_DEAD_DEFAULT	1
+#  endif
+#  ifndef FILL_ALIVE_DEFAULT
+#    define FILL_ALIVE_DEFAULT	1
+#  endif
+#  ifndef FILL_CHECK_DEFAULT
+#    define FILL_CHECK_DEFAULT	1
+#  endif
+
 static IV MallocCfg[MallocCfg_last] = {
   FIRST_SBRK,
   MIN_SBRK,
@@ -1040,9 +1050,9 @@ static IV MallocCfg[MallocCfg_last] = {
   SBRK_ALLOW_FAILURES,
   SBRK_FAILURE_PRICE,
   SBRK_ALLOW_FAILURES * SBRK_FAILURE_PRICE,	/* sbrk_goodness */
-  1,			/* FILL_DEAD */
-  1,			/* FILL_ALIVE */
-  1,			/* FILL_CHECK */
+  FILL_DEAD_DEFAULT,	/* FILL_DEAD */
+  FILL_ALIVE_DEFAULT,	/* FILL_ALIVE */
+  FILL_CHECK_DEFAULT,	/* FILL_CHECK */
   0,			/* MallocCfg_skip_cfg_env */
   0,			/* MallocCfg_cfg_env_read */
   0,			/* MallocCfg_emergency_buffer_size */

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About