Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 23 Aug 2012 13:55:45 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: build musl with clang

On Thu, Aug 23, 2012 at 07:11:53PM +0600, agent wrote:
> >there is another known bug in clang which will lead to calloc
> >getting wrongly optimized away, because clang disrespects
> >-ffree-standing. Richard Pennington wanted to reported this to the
> >LLVM maillist months ago, but afaik he still hasn't done this.
> i was investigating the possibility of using clang + musl for
> writing a new program, not for porting existing software, so it may
> be possible to avoid using some functions in reasonable scale, or
> change any component in this bundle.
> and does that bug affect a whole *alloc family or just calloc?

The bug is that clang assumes the memory returned from malloc has
indeterminate contents, which is only a valid assumption on a hosted
implementation. On a freestanding one, malloc is just another ordinary
function with no special semantics. Anyway, based on the wrong
assumption, it optimizes out the zero-fill code that's of the form

for (i=0; i<n; i++) if (mem[i]) mem[i] = 0;

I am not willing to remove the if, because it serves a valuable
purpose: it avoids writing to pages that are already all-zero, which
in turn reduces swap pressure/dirty pages.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.