public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function
@ 2010-11-09 23:14 bruno at clisp dot org
  2010-11-09 23:20 ` [Bug libc/12204] " bruno at clisp dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: bruno at clisp dot org @ 2010-11-09 23:14 UTC (permalink / raw)
  To: glibc-bugs

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

           Summary: glibc does has no POSIX compliant strerror_r function
           Product: glibc
           Version: 2.8
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: bruno@clisp.org


glibc has two strerror_r functions, declared in <string.h> depending on
feature macros. But none of them is POSIX compliant.

The one which is in effect when _GNU_SOURCE=1 has the declaration
char *strerror_r (int, char *, size_t). It has a different return type
and therefore a different calling convention than the POSIX function.
Test case:
=================================================
#define _GNU_SOURCE 1
#include <string.h>
#include <stdio.h>

int main()
{
  char buf[100];
  char *s = strerror_r (-2, buf, sizeof (buf));
  printf ("result: %s\n", s);
  return 0;
}
=================================================

The one which is in effect when _GNU_SOURCE is undefined and
_POSIX_C_SOURCE=200112L has the declaration
int strerror_r (int, char *, size_t), which is POSIX compatible,
but it has a different return value convention in case of failure.
POSIX:2001 and POSIX:2008 say that in case of failure the strerror_r
function should return "an error number"; this is the same wording
as for pthread_create, pthread_mutex_lock, etc. However, the glibc
function returns -1 and sets errno to the error number instead.
Test case:
========================================================================
#define _POSIX_C_SOURCE 200112L
#include <string.h>
#include <errno.h>
#include <stdio.h>

int main()
{
  char buf[100] = "______";
  int r;

  r = strerror_r (-2, buf, sizeof (buf));
  if (r == 0)
    printf ("result: success %s\n", buf);
  else if (r > 0)
    printf ("result: failure %d %s\n", r, buf);
  else
    printf ("result: non-POSIX failure %d %d %s\n", r, errno, buf);

  r = strerror_r (EACCES, buf, 3);
  if (r == 0)
    printf ("result: success %s\n", buf);
  else if (r > 0)
    printf ("result: failure %d %s\n", r, buf);
  else
    printf ("result: non-POSIX failure %d %d %s\n", r, errno, buf);

  return 0;
}
==========================================================================
Expected result:
result: failure 22 ______
result: failure 34 ______

Actual result:
result: non-POSIX failure -1 22 ______
result: non-POSIX failure -1 34 ______

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
  2010-11-09 23:20 ` [Bug libc/12204] " bruno at clisp dot org
@ 2010-11-09 23:20 ` bruno at clisp dot org
  2010-11-10  8:14 ` drepper.fsp at gmail dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bruno at clisp dot org @ 2010-11-09 23:20 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #2 from Bruno Haible <bruno at clisp dot org> 2010-11-09 23:20:25 UTC ---
The fix could either be to change the behaviour of __xpg_strerror_r
so that it returns the error number instead of assigning it to errno,
or to introduce a new function __posix_strerror_r and enable it in <string.h>
under the appropriate conditions.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
@ 2010-11-09 23:20 ` bruno at clisp dot org
  2010-11-09 23:20 ` bruno at clisp dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bruno at clisp dot org @ 2010-11-09 23:20 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #1 from Bruno Haible <bruno at clisp dot org> 2010-11-09 23:17:17 UTC ---
Created attachment 5117
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5117
test case

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
  2010-11-09 23:20 ` [Bug libc/12204] " bruno at clisp dot org
  2010-11-09 23:20 ` bruno at clisp dot org
@ 2010-11-10  8:14 ` drepper.fsp at gmail dot com
  2010-11-10  9:10 ` schwab@linux-m68k.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: drepper.fsp at gmail dot com @ 2010-11-10  8:14 UTC (permalink / raw)
  To: glibc-bugs

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

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #3 from Ulrich Drepper <drepper.fsp at gmail dot com> 2010-11-10 08:14:11 UTC ---
What do other OSes do?  What's the behavior on Solaris?  Common practice IIRC
was at least to return -1.  Might just be that the incorrect wording was copied
into the strerror_r spec.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (2 preceding siblings ...)
  2010-11-10  8:14 ` drepper.fsp at gmail dot com
@ 2010-11-10  9:10 ` schwab@linux-m68k.org
  2010-11-11  9:36 ` bruno at clisp dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: schwab@linux-m68k.org @ 2010-11-10  9:10 UTC (permalink / raw)
  To: glibc-bugs

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

--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> 2010-11-10 09:10:45 UTC ---
According to http://www.freebsd.org/cgi/man.cgi *BSD and Solaris both return
the error number.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (3 preceding siblings ...)
  2010-11-10  9:10 ` schwab@linux-m68k.org
@ 2010-11-11  9:36 ` bruno at clisp dot org
  2010-12-25 19:17 ` drepper.fsp at gmail dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: bruno at clisp dot org @ 2010-11-11  9:36 UTC (permalink / raw)
  To: glibc-bugs

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

Bruno Haible <bruno at clisp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |ASSIGNED

--- Comment #5 from Bruno Haible <bruno at clisp dot org> 2010-11-11 09:36:21 UTC ---
> What do other OSes do?  What's the behavior on Solaris?

Here are the results of the test program:

Solaris 10:
result: failure 22 Unknown error
result: failure 34 Unknown error

FreeBSD 6.4, OpenBSD 4.4:
result: failure 22 Unknown error: -2
result: failure 34 Pe

HP-UX 11.31:
result: failure 22 ______
result: failure 34 ______

AIX 6.1:
result: success Error -2 occurred.
result: success Pe

Tru64 5.1:
result: non-POSIX failure -1 22 Error -2 occurred.
result: success Pe

You can see that the major Unices use the POSIX compliant return value
convention. Tru64 is the only one to use the (-1,errno) return value.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (4 preceding siblings ...)
  2010-11-11  9:36 ` bruno at clisp dot org
@ 2010-12-25 19:17 ` drepper.fsp at gmail dot com
  2011-05-18 23:34 ` eblake at redhat dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: drepper.fsp at gmail dot com @ 2010-12-25 19:17 UTC (permalink / raw)
  To: glibc-bugs

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

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #6 from Ulrich Drepper <drepper.fsp at gmail dot com> 2010-12-25 18:57:57 UTC ---
I've changed the __xpg_strerror_r implementations.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (5 preceding siblings ...)
  2010-12-25 19:17 ` drepper.fsp at gmail dot com
@ 2011-05-18 23:34 ` eblake at redhat dot com
  2013-02-08 19:35 ` dank at kegel dot com
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: eblake at redhat dot com @ 2011-05-18 23:34 UTC (permalink / raw)
  To: glibc-bugs

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

Eric Blake <eblake at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |12782

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (6 preceding siblings ...)
  2011-05-18 23:34 ` eblake at redhat dot com
@ 2013-02-08 19:35 ` dank at kegel dot com
  2014-02-16 18:28 ` jackie.rosen at hushmail dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dank at kegel dot com @ 2013-02-08 19:35 UTC (permalink / raw)
  To: glibc-bugs

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

dank at kegel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dank at kegel dot com

--- Comment #7 from dank at kegel dot com 2013-02-08 19:35:04 UTC ---
See also http://austingroupbugs.net/view.php?id=655
Looks like strerror_r is being retired because of the confusion.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (7 preceding siblings ...)
  2013-02-08 19:35 ` dank at kegel dot com
@ 2014-02-16 18:28 ` jackie.rosen at hushmail dot com
  2014-05-28 19:41 ` schwab at sourceware dot org
  2014-06-30  6:29 ` fweimer at redhat dot com
  10 siblings, 0 replies; 12+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 18:28 UTC (permalink / raw)
  To: glibc-bugs

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

Jackie Rosen <jackie.rosen at hushmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jackie.rosen at hushmail dot com

--- Comment #8 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.

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


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (8 preceding siblings ...)
  2014-02-16 18:28 ` jackie.rosen at hushmail dot com
@ 2014-05-28 19:41 ` schwab at sourceware dot org
  2014-06-30  6:29 ` fweimer at redhat dot com
  10 siblings, 0 replies; 12+ messages in thread
From: schwab at sourceware dot org @ 2014-05-28 19:41 UTC (permalink / raw)
  To: glibc-bugs

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

Andreas Schwab <schwab at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jackie.rosen at hushmail dot com   |

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


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

* [Bug libc/12204] glibc does has no POSIX compliant strerror_r function
  2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
                   ` (9 preceding siblings ...)
  2014-05-28 19:41 ` schwab at sourceware dot org
@ 2014-06-30  6:29 ` fweimer at redhat dot com
  10 siblings, 0 replies; 12+ messages in thread
From: fweimer at redhat dot com @ 2014-06-30  6:29 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

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


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

end of thread, other threads:[~2014-06-30  6:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-09 23:14 [Bug libc/12204] New: glibc does has no POSIX compliant strerror_r function bruno at clisp dot org
2010-11-09 23:20 ` [Bug libc/12204] " bruno at clisp dot org
2010-11-09 23:20 ` bruno at clisp dot org
2010-11-10  8:14 ` drepper.fsp at gmail dot com
2010-11-10  9:10 ` schwab@linux-m68k.org
2010-11-11  9:36 ` bruno at clisp dot org
2010-12-25 19:17 ` drepper.fsp at gmail dot com
2011-05-18 23:34 ` eblake at redhat dot com
2013-02-08 19:35 ` dank at kegel dot com
2014-02-16 18:28 ` jackie.rosen at hushmail dot com
2014-05-28 19:41 ` schwab at sourceware dot org
2014-06-30  6:29 ` 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).