public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/10320] New: erand48 implementation not thread safe but POSIX says it should be
@ 2009-06-23 19:25 simon at josefsson dot org
  2009-06-23 20:11 ` [Bug libc/10320] " simon at josefsson dot org
  0 siblings, 1 reply; 2+ messages in thread
From: simon at josefsson dot org @ 2009-06-23 19:25 UTC (permalink / raw)
  To: glibc-bugs

POSIX specification for erand48:

http://www.opengroup.org/onlinepubs/9699919799/functions/erand48.html

It doesn't say the function may be non-reentrant, which IIUC, means it should be
thread safe.  However the implementation of erand48 does use a global variable:

http://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/erand48.c;hb=HEAD

The variable is __libc_drand48_data and is defined in:

http://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/drand48-iter.c;hb=HEAD

I can't find anyplace where it is made thread-local, so I'm assuming it is a
real global variable.

As far as I can tell, there is no requirement in the specification that erand48
update the global drand48 state.

-- 
           Summary: erand48 implementation not thread safe but POSIX says it
                    should be
           Product: glibc
           Version: 2.11
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: simon at josefsson dot org
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=10320

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/10320] erand48 implementation not thread safe but POSIX says it should be
  2009-06-23 19:25 [Bug libc/10320] New: erand48 implementation not thread safe but POSIX says it should be simon at josefsson dot org
@ 2009-06-23 20:11 ` simon at josefsson dot org
  0 siblings, 0 replies; 2+ messages in thread
From: simon at josefsson dot org @ 2009-06-23 20:11 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From simon at josefsson dot org  2009-06-23 20:10 -------
By reading code, jrand48, lcong48, nrand48, seed48, and srand48 also uses the
variable __libc_drand48_data so may be subjec to the same concern.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=10320

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2009-06-23 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-23 19:25 [Bug libc/10320] New: erand48 implementation not thread safe but POSIX says it should be simon at josefsson dot org
2009-06-23 20:11 ` [Bug libc/10320] " simon at josefsson dot org

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