From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/511 Path: news.gmane.org!not-for-mail From: aep Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] properly terminate linked link of dsos Date: Wed, 12 Oct 2011 16:46:30 +0200 Message-ID: <05e2d053cdb7c8726eb0f9bcebbbf048@exys.org> References: <1318427173.165420.11829@legion> <20111012140141.GX132@brightrain.aerifal.cx> <37ae4188867ea36022c6305ae687bd23@exys.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1318430809 5314 80.91.229.12 (12 Oct 2011 14:46:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 12 Oct 2011 14:46:49 +0000 (UTC) To: Original-X-From: musl-return-512-gllmg-musl=m.gmane.org@lists.openwall.com Wed Oct 12 16:46:45 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1RE04y-0007Yy-8l for gllmg-musl@lo.gmane.org; Wed, 12 Oct 2011 16:46:44 +0200 Original-Received: (qmail 13503 invoked by uid 550); 12 Oct 2011 14:46:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 13495 invoked from network); 12 Oct 2011 14:46:43 -0000 In-Reply-To: <37ae4188867ea36022c6305ae687bd23@exys.org> X-Sender: aep@exys.org User-Agent: Roundcube Webmail/0.5.4 Xref: news.gmane.org gmane.linux.lib.musl.general:511 Archived-At: clang optimized away the check in calloc.c to false. I can work around it with a cast to something volatile: diff --git a/src/malloc/calloc.c b/src/malloc/calloc.c index 9d57456..22f2c01 100644 --- a/src/malloc/calloc.c +++ b/src/malloc/calloc.c @@ -13,8 +13,10 @@ void *calloc(size_t m, size_t n) n *= m; p = malloc(n); if (!p) return 0; + + volatile long long dont_optimize_me = p; /* Only do this for non-mmapped chunks */ - if (((size_t *)p)[-1] & 7) { + if (((size_t *)dont_optimize_me)[-1] & 7) { /* Only write words that are not already zero */ m = (n + sizeof *z - 1)/sizeof *z; for (z=p; m; m--, z++) if (*z) *z=0;