This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug dynamic-link/16585] dlsym() shouldn't be declared as leaf
- From: "carlos at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 14 Feb 2014 15:50:55 +0000
- Subject: [Bug dynamic-link/16585] dlsym() shouldn't be declared as leaf
- Auto-submitted: auto-generated
- References: <bug-16585-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=16585
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |WAITING
CC| |carlos at redhat dot com
--- Comment #1 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Stefan Seefeld from comment #0)
> We are using a preload library with approximately this code:
>
> static struct mystruct *state;
> ...
> void foo()
> {
> // access 'state' here
> }
>
> void bar()
> {
> state = ...; // (1)
> dlsym(...); // (2)
> state = ...; // (3)
> }
>
> The compiler appears to optimize away statement (1), thinking that it is
> redundant. However, in reality dlsym(...) implicitly calls 'foo()' above (we
> use our own malloc wrappers...), which reads 'state', and consequently
> crashes the application since the attempted initialization of the variable
> has disappeared.
> The reason is that dlsym() is declared "leaf" (by means of __THROW).
>
> Changing the dlsym() declaration from __THROW to __THROWNL should fix this.
Would this not generate worse code for other applications calling dlsym(...)
and not modifying state in the current compilation unit?
Why isn't the solution to mark state as volatile?
--
You are receiving this mail because:
You are on the CC list for the bug.