From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13141 invoked by alias); 24 Apr 2006 09:07:49 -0000 Received: (qmail 12989 invoked by uid 22791); 24 Apr 2006 09:07:48 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 24 Apr 2006 09:07:43 +0000 Received: from sunsite.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.1/8.13.1) with ESMTP id k3O97X8h018753; Mon, 24 Apr 2006 11:07:33 +0200 Received: (from jj@localhost) by sunsite.mff.cuni.cz (8.13.1/8.13.1/Submit) id k3O97Xf5018752; Mon, 24 Apr 2006 11:07:33 +0200 Date: Mon, 24 Apr 2006 09:07:00 -0000 From: Jakub Jelinek To: Ulrich Drepper , Roland McGrath Cc: Glibc hackers Subject: [PATCH] Prevent people shooting themselves in the foot with MALLOC_CHECK_= Message-ID: <20060424090733.GC4651@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="liOOAslEiF7prFVr" Content-Disposition: inline User-Agent: Mutt/1.4.1i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2006-04/txt/msg00010.txt.bz2 --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 594 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 --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=X Content-length: 573 2006-04-24 Jakub Jelinek * 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(); } --liOOAslEiF7prFVr Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Y Content-length: 560 2006-04-24 Jakub Jelinek * 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(); } --liOOAslEiF7prFVr--