public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/1890] New: strerror() unnecessarily non thread-safe
@ 2005-11-19 15:15 stefan dot puiu at gmail dot com
  2005-11-22 18:13 ` [Bug libc/1890] " drepper at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: stefan dot puiu at gmail dot com @ 2005-11-19 15:15 UTC (permalink / raw)
  To: glibc-bugs

Because of some confusing information in the strerror() manual page, I decided
to check the glibc-2.3.6 source and see for myself, and was dissapointed to see
how strerror_r() (sysdeps/generic/_strerror.c) and strerror()
(string/strerror.c) are implemented. The only reason strerror() is not thread
safe is because it insists keeping a global buffer around, which it mallocs when
needed and then fills it in when it gets called with an invalid errno, with a
string like "Unknown error: <errno>". I would say this is a useless
complication, buys you nothing (you can examine the value without strerror()
supplying it back to you in a buffer), and forces people to use the non-POSIX
strerror_r() (which returns a char*), which only uses the supplied buffer when
the aforementioned situation occurs, further confusing people. 

I suggest changing strerror so that it simply returns "Unknown error" when an
invalid errno is supplied, and deprecating strerror_r. I can provide a patch if
needed. 

Note: both Solaris and HP-UX have thread-safe strerror() functions, so this will
ease the work of people developing applications for multiple Unices.

-- 
           Summary: strerror() unnecessarily non thread-safe
           Product: glibc
           Version: 2.3.6
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: stefan dot puiu at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


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

------- 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] 13+ messages in thread

end of thread, other threads:[~2023-12-13  9:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-1890-131@http.sourceware.org/bugzilla/>
2020-12-21  2:43 ` [Bug libc/1890] strerror() unnecessarily non thread-safe jscott at posteo dot net
2023-06-15  9:48 ` fweimer at redhat dot com
2023-06-15  9:50 ` fweimer at redhat dot com
2023-10-26 23:20 ` gabravier at gmail dot com
2023-11-01  1:59 ` bruno at clisp dot org
2023-12-12 11:40 ` fweimer at redhat dot com
2023-12-12 12:21 ` bruno at clisp dot org
2023-12-13  9:39 ` fweimer at redhat dot com
2005-11-19 15:15 [Bug libc/1890] New: " stefan dot puiu at gmail dot com
2005-11-22 18:13 ` [Bug libc/1890] " drepper at redhat dot com
2005-11-23  7:35 ` stefan dot puiu at gmail dot com
2005-11-23  8:31 ` drepper at redhat dot com
2005-11-23  9:15 ` stefan dot puiu at gmail dot com
2005-11-23  9:26 ` stefan dot puiu at gmail 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).