public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug dynamic-link/16585] New: dlsym() shouldn't be declared as leaf
@ 2014-02-14 14:40 stefan at codesourcery dot com
  2014-02-14 15:38 ` [Bug dynamic-link/16585] " amonakov at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: stefan at codesourcery dot com @ 2014-02-14 14:40 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=16585

            Bug ID: 16585
           Summary: dlsym() shouldn't be declared as leaf
           Product: glibc
           Version: 2.18
            Status: NEW
          Severity: normal
          Priority: P2
         Component: dynamic-link
          Assignee: unassigned at sourceware dot org
          Reporter: stefan at codesourcery dot com

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

end of thread, other threads:[~2014-06-13  8:15 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14 14:40 [Bug dynamic-link/16585] New: dlsym() shouldn't be declared as leaf stefan at codesourcery dot com
2014-02-14 15:38 ` [Bug dynamic-link/16585] " amonakov at gmail dot com
2014-02-14 15:51 ` carlos at redhat dot com
2014-02-14 16:07 ` stefan at codesourcery dot com
2014-02-14 16:27 ` amonakov at gmail dot com
2014-02-14 16:34 ` jakub at redhat dot com
2014-02-14 16:37 ` jakub at redhat dot com
2014-02-14 16:54 ` amonakov at gmail dot com
2014-02-14 18:26 ` bugdal at aerifal dot cx
2014-02-14 22:09 ` carlos at redhat dot com
2014-02-15  8:32 ` amonakov at gmail dot com
2014-02-21 18:25 ` carlos at redhat dot com
2014-06-13  8:15 ` fweimer at redhat dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).