public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [Bug general/21010] New: Incompatible with MUSL libc: strerror_r
@ 2016-12-30 21:14 luizluca at gmail dot com
  2016-12-30 21:29 ` [Bug general/21010] " luizluca at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: luizluca at gmail dot com @ 2016-12-30 21:14 UTC (permalink / raw)
  To: elfutils-devel

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

            Bug ID: 21010
           Summary: Incompatible with MUSL libc: strerror_r
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: general
          Assignee: unassigned at sourceware dot org
          Reporter: luizluca at gmail dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

From original bug 21002

- I have to think about that strerror_r replacement. Normally we expect just a
static string describing a known errno. But I see we have to handle unknown
numbers too. hmmm.

The used behavior is GNU-specific:

       The GNU-specific strerror_r() returns a pointer to a string containing
the error message.  This may be either a pointer to a string that the function
stores  in  buf,  or  a  pointer  to  some
       (immutable)  static  string (in which case buf is unused).  If the
function stores a string in buf, then at most buflen bytes are stored (the
string may be truncated if buflen is too small and
       errnum is unknown).  The string always includes a terminating null byte
('\0').

A portable way to solve this is stick to the XSI-compliant behavior (as in the
patch).

--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -140,6 +140,7 @@ __libdwfl_seterrno (Dwfl_Error error)
 const char *
 dwfl_errmsg (int error)
 {
+  static __thread char s[64] = "";
   if (error == 0 || error == -1)
     {
       int last_error = global_error;
@@ -154,7 +155,8 @@ dwfl_errmsg (int error)
   switch (error &~ 0xffff)
     {
     case OTHER_ERROR (ERRNO):
-      return strerror_r (error & 0xffff, "bad", 0);
+      strerror_r (error & 0xffff, s, sizeof(s));
+      return s;
     case OTHER_ERROR (LIBELF):
       return elf_errmsg (error & 0xffff);
     case OTHER_ERROR (LIBDW):


However, according to the comments on the original bug, it might be interesting
to find a new way to deal with it.

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

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

* [Bug general/21010] Incompatible with MUSL libc: strerror_r
  2016-12-30 21:14 [Bug general/21010] New: Incompatible with MUSL libc: strerror_r luizluca at gmail dot com
@ 2016-12-30 21:29 ` luizluca at gmail dot com
  2017-05-24 20:19 ` florian at openwrt dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: luizluca at gmail dot com @ 2016-12-30 21:29 UTC (permalink / raw)
  To: elfutils-devel

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

Luiz Angelo Daros de Luca <luizluca at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |21002


Referenced Bugs:

https://sourceware.org/bugzilla/show_bug.cgi?id=21002
[Bug 21002] Incompatible with MUSL libc
-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug general/21010] Incompatible with MUSL libc: strerror_r
  2016-12-30 21:14 [Bug general/21010] New: Incompatible with MUSL libc: strerror_r luizluca at gmail dot com
  2016-12-30 21:29 ` [Bug general/21010] " luizluca at gmail dot com
@ 2017-05-24 20:19 ` florian at openwrt dot org
  2017-05-24 20:20 ` florian at openwrt dot org
  2021-02-05 14:49 ` mark at klomp dot org
  3 siblings, 0 replies; 5+ messages in thread
From: florian at openwrt dot org @ 2017-05-24 20:19 UTC (permalink / raw)
  To: elfutils-devel

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

Florian Fainelli <florian at openwrt dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |florian at openwrt dot org

--- Comment #1 from Florian Fainelli <florian at openwrt dot org> ---
strerror_r is marked with __must_check on glibc, and this leads to the
following warnings/errors (with Werror):

dwfl_error.c: In function 'dwfl_errmsg':
dwfl_error.c:158:18: error: ignoring return value of 'strerror_r', declared
with attribute warn_unused_result [-Werror=unused-result]
       strerror_r (error & 0xffff, s, sizeof(s));
                  ^
cc1: all warnings being treated as errors

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

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

* [Bug general/21010] Incompatible with MUSL libc: strerror_r
  2016-12-30 21:14 [Bug general/21010] New: Incompatible with MUSL libc: strerror_r luizluca at gmail dot com
  2016-12-30 21:29 ` [Bug general/21010] " luizluca at gmail dot com
  2017-05-24 20:19 ` florian at openwrt dot org
@ 2017-05-24 20:20 ` florian at openwrt dot org
  2021-02-05 14:49 ` mark at klomp dot org
  3 siblings, 0 replies; 5+ messages in thread
From: florian at openwrt dot org @ 2017-05-24 20:20 UTC (permalink / raw)
  To: elfutils-devel

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

--- Comment #2 from Florian Fainelli <florian at openwrt dot org> ---
(In reply to Florian Fainelli from comment #1)
> strerror_r is marked with __must_check on glibc, and this leads to the
> following warnings/errors (with Werror):

Sorry, not __must_check, but the return value becomes unused here.

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

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

* [Bug general/21010] Incompatible with MUSL libc: strerror_r
  2016-12-30 21:14 [Bug general/21010] New: Incompatible with MUSL libc: strerror_r luizluca at gmail dot com
                   ` (2 preceding siblings ...)
  2017-05-24 20:20 ` florian at openwrt dot org
@ 2021-02-05 14:49 ` mark at klomp dot org
  3 siblings, 0 replies; 5+ messages in thread
From: mark at klomp dot org @ 2021-02-05 14:49 UTC (permalink / raw)
  To: elfutils-devel

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at klomp dot org
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Mark Wielaard <mark at klomp dot org> ---
commit 8db222e36ae777e6aec8c61c616838a86258e99f
Author: Érico Rolim <erico.erc@gmail.com>
Date:   Mon Feb 1 21:16:56 2021 -0300

    libdwfl: use GNU strerror_r only when available.

    Some C libraries don't provide the GNU version of strerror_r, only the
    XSI-compliant one. We use the GNU version when available, since it fits
    the code better, and otherwise use the XSI-compliant one.

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

    Signed-off-by: Érico Rolim <erico.erc@gmail.com>

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

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

end of thread, other threads:[~2021-02-05 14:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30 21:14 [Bug general/21010] New: Incompatible with MUSL libc: strerror_r luizluca at gmail dot com
2016-12-30 21:29 ` [Bug general/21010] " luizluca at gmail dot com
2017-05-24 20:19 ` florian at openwrt dot org
2017-05-24 20:20 ` florian at openwrt dot org
2021-02-05 14:49 ` mark at klomp 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).