This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug dynamic-link/16585] dlsym() shouldn't be declared as leaf


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]