From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Solving the recursive memcpy/memset/etc. issue
Date: Thu, 1 Aug 2013 22:52:44 -0400 [thread overview]
Message-ID: <20130802025244.GM221@brightrain.aerifal.cx> (raw)
In-Reply-To: <20130801004940.GA20323@brightrain.aerifal.cx>
On Wed, Jul 31, 2013 at 08:49:40PM -0400, Rich Felker wrote:
> OK, so now that it's hit us for real, what should we do about GCC
> generating code for memcpy, memset, etc. which might contain infinite
> recursion? Aside from the ARM issue (which was separate), we know the
> option causing this bad code generation, and it can be disabled via
> -fno-tree-loop-distribute-patterns. However, if GCC policy is that
> they consider the compiler entitled to generate calls to
> memcpy/memset/memmove/memcmp whenever it wants, then we're just going
> to be playing whack-a-mole.
For now, I solved it with just this option, and also added some more
asm for x86[_64].
> The only fully viable option I see is replacing the code for these
> functions with code that uses volatile objects so as to make
> optimization utterly impossible. This will of course make them
> incredibly slow, but at least we would have safe, working C code, and
> we could add asm for each supported arch.
I'd actually like to experiment with some ideas for volatile that
don't make the C slow. If the compiler really honors volatile, it
seems like you can write C code in such a way where the compiler has
to implement it pretty close to the abstract machine -- but you can be
selective about it, so as to allow the compiler some freedom.
> An alternative might be to test the compiler in configure to determine
> if, with the selected CFLAGS, it generates recursive code for these
> functions, and if so, defining a macro that causes musl to revert to
> the volatile code.
This is not in the workaround I committed, but could be added..
Rich
prev parent reply other threads:[~2013-08-02 2:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-01 0:49 Rich Felker
2013-08-01 6:05 ` Luca Barbato
2013-08-01 6:20 ` Rich Felker
2013-08-01 8:03 ` Luca Barbato
2013-08-01 8:26 ` Jens Gustedt
2013-08-01 17:48 ` Rich Felker
2013-08-02 2:52 ` Rich Felker [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130802025244.GM221@brightrain.aerifal.cx \
--to=dalias@aerifal.cx \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).