mailing list of musl libc
 help / color / mirror / code / Atom feed
* Solving the recursive memcpy/memset/etc. issue
@ 2013-08-01  0:49 Rich Felker
  2013-08-01  6:05 ` Luca Barbato
  2013-08-02  2:52 ` Rich Felker
  0 siblings, 2 replies; 7+ messages in thread
From: Rich Felker @ 2013-08-01  0:49 UTC (permalink / raw)
  To: musl

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.

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.

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.

Other ideas? For now, if -fno-tree-loop-distribute-patterns fixes it
(still waiting on confirmation for this) I'm going to commit that to
configure, but it doesn't seem like a viable long-term solution.

My ideal outcome would be a promise from the GCC developers that, in
future GCC versions, -ffreestanding implies disabling any options
which would generate calls to the mem* functions. However that sounds
unlikely.

Rich


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

end of thread, other threads:[~2013-08-02  2:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01  0:49 Solving the recursive memcpy/memset/etc. issue 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

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).