public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Prevent people shooting themselves in the foot with MALLOC_CHECK_=
@ 2006-04-24  9:07 Jakub Jelinek
  2006-04-24 17:25 ` Ulrich Drepper
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2006-04-24  9:07 UTC (permalink / raw)
  To: Ulrich Drepper, Roland McGrath; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

Hi!

If malloc.c didn't try to special case MALLOC_CHECK_= (empty string in
the env var), I'd say why bother, but as it does, it probably doesn't
hurt to handle it gracefully.

ATM apps segfault, because in that case mallopt (M_CHECK_ACTION, something)
is not called, but __malloc_check_init is.  But in that case
malloc_consolidate has not been called and we die later on.

I'm attaching 2 patches, one which handles MALLOC_CHECK_= as if
MALLOC_CHECK_=3 was given (3 stands for DEFAULT_CHECK_ACTION here),
the other ignores MALLOC_CHECK_ var completely if it contains an empty
string.

	Jakub

[-- Attachment #2: X --]
[-- Type: text/plain, Size: 573 bytes --]

2006-04-24  Jakub Jelinek  <jakub@redhat.com>

	* malloc/arena.c (ptmalloc_init): Call mALLOPt with
	DEFAULT_CHECK_ACTION if MALLOC_CHECK_ env var contains an empty
	string.

--- libc/malloc/arena.c	6 Mar 2006 06:18:35 -0000	1.20
+++ libc/malloc/arena.c	24 Apr 2006 08:54:16 -0000
@@ -552,7 +552,7 @@ ptmalloc_init (void)
   s = getenv("MALLOC_CHECK_");
 #endif
   if(s) {
-    if(s[0]) mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0'));
+    mALLOPt(M_CHECK_ACTION, s[0] ? (int)(s[0] - '0') : DEFAULT_CHECK_ACTION);
     if (check_action != 0)
       __malloc_check_init();
   }

[-- Attachment #3: Y --]
[-- Type: text/plain, Size: 560 bytes --]

2006-04-24  Jakub Jelinek  <jakub@redhat.com>

	* malloc/arena.c (ptmalloc_init): Don't call __malloc_check_init
	if MALLOC_CHECK_ env var contains an empty string.

--- libc/malloc/arena.c	6 Mar 2006 06:18:35 -0000	1.20
+++ libc/malloc/arena.c	24 Apr 2006 08:55:04 -0000
@@ -551,8 +551,8 @@ ptmalloc_init (void)
     }
   s = getenv("MALLOC_CHECK_");
 #endif
-  if(s) {
-    if(s[0]) mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0'));
+  if(s && s[0]) {
+    mALLOPt(M_CHECK_ACTION, (int)(s[0] - '0'));
     if (check_action != 0)
       __malloc_check_init();
   }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Prevent people shooting themselves in the foot with MALLOC_CHECK_=
  2006-04-24  9:07 [PATCH] Prevent people shooting themselves in the foot with MALLOC_CHECK_= Jakub Jelinek
@ 2006-04-24 17:25 ` Ulrich Drepper
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Drepper @ 2006-04-24 17:25 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Glibc hackers

[-- Attachment #1: Type: text/plain, Size: 151 bytes --]

I used the second patch which simply ignores the variable.

-- 
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 253 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-24 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-24  9:07 [PATCH] Prevent people shooting themselves in the foot with MALLOC_CHECK_= Jakub Jelinek
2006-04-24 17:25 ` Ulrich Drepper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).