Bug 31080 - strerrorname_np and strerror don't know about ENOSYM and EREMOTERELEASE on Linux/hppa
Summary: strerrorname_np and strerror don't know about ENOSYM and EREMOTERELEASE on Li...
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.37
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-21 14:50 UTC by Bruno Haible
Modified: 2023-11-23 19:56 UTC (History)
5 users (show)

See Also:
Host: hppa-unknown-linux-gnu
Target:
Build:
Last reconfirmed:


Attachments
test case foo.c (155 bytes, text/x-csrc)
2023-11-21 14:50 UTC, Bruno Haible
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bruno Haible 2023-11-21 14:50:49 UTC
Created attachment 15225 [details]
test case foo.c

The function strerrorname_np is supposed to return non-NULL for all defined
errno values. https://www.gnu.org/software/libc/manual/html_node/Error-Messages.html

On Linux/hppa, for the errnos with names
  ENOSYM
  EREMOTERELEASE
it returns NULL.

$ grep -rw ENOSYM /usr/include
/usr/include/asm/errno.h:#define ENOSYM         215     /* symbol does not exist in executable */
$ grep -rw EREMOTERELEASE /usr/include 
/usr/include/asm/errno.h:#define        EREMOTERELEASE  240     /* Remote peer released connection */

How to reproduce:
$ gcc -Wall foo.c
$ ./a.out

Expected output:
strerrorname_np (ENOSYM) = "ENOSYM"
strerrorname_np (EREMOTERELEASE) = "EREMOTERELEASE"
strerror (ENOSYM) = Symbol does not exist in executable
strerror (EREMOTERELEASE) = Remote peer released connection

Actual output:
strerrorname_np (ENOSYM) = (null)
strerrorname_np (EREMOTERELEASE) = (null)
strerror (ENOSYM) = Unknown error 215
strerror (EREMOTERELEASE) = Unknown error 240


Seen on T2-SDE Linux, with glibc 2.37.
Comment 1 Adhemerval Zanella 2023-11-21 15:00:28 UTC
This is because they are not defined or described in the error codes [1].  They also seem not to be returned by the kernel, so not sure how useful adding these would be for hppa-linux-gnu.

[1] https://www.gnu.org/software/libc/manual/html_node/Error-Codes.html
Comment 2 Bruno Haible 2023-11-21 15:28:48 UTC
(In reply to Adhemerval Zanella from comment #1)
> They also seem not to be returned by the kernel

Indeed.

Then you could ask the kernel people to remove these two errnos from linux/arch/parisc/include/uapi/asm/errno.h. Similar to what has been done with ENOTSUP in
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/arch/parisc/include/uapi/asm/errno.h?id=93cb8e20d56be40c541475f77b5f565fbb385a4b
Comment 3 John David Anglin 2023-11-23 16:44:43 UTC
ENOSYM and EREMOTERELEASE are HP-UX defines and probably can be removed.

/* Things in HP-UX not in XPG3, POSIX or ANSI C */
#ifdef _INCLUDE_HPUX_SOURCE
/* The error numbers between 37 and 44 are not produced by HP-UX. They
   will track whatever the UNIX(tm) system does in the future */
#define ECHRNG  37      /* Channel number out of range          */
#define EL2NSYNC 38     /* Level 2 not synchronized             */
#define EL3HLT  39      /* Level 3 halted                       */
#define EL3RST  40      /* Level 3 reset                        */
#define ELNRNG  41      /* Link number out of range             */
#define EUNATCH 42      /* Protocol driver not attached         */
#define ENOCSI  43      /* No CSI structure available           */
#define EL2HLT  44      /* Level 2 halted                       */

#define ENONET          50      /* Machine is not on the network        */
#define ENOPKG          55      /* Package not installed                */
#define EADV            58      /* advertise error */
#define ESRMNT          59      /* srmount error */
#define ECOMM           60      /* Communication error on send          */
#define EDOTDOT         66      /* Cross mount point (not really error)*/


#define ENOSYM          215     /* symbol does not exist in executable  */

/* disk quotas errors */
#  define       EUSERS   68     /* For Sun compatibilty, will not occur.*/

/* Network File System */
#  define       EREMOTE         71      /* Too many levels of remote in path */

/* ipc/network software */

/* argument errors */
#  define ESOCKTNOSUPPORT       222     /* Socket type not supported */
#  define EPFNOSUPPORT          224     /* Protocol family not supported */

        /* operational errors */
#  define ENETRESET             230     /* Network dropped connection on
                                           reset */
#  define ESHUTDOWN             236     /* Can't send after socket shutdown */
#  define ETOOMANYREFS          237     /* Too many references: can't splice */
#  define EREFUSED              ECONNREFUSED    /* Double define for NFS*/
#  define EREMOTERELEASE        240     /* Remote peer released connection */
#  define EHOSTDOWN             241     /* Host is down */


#endif /* _INCLUDE_HPUX_SOURCE */
Comment 4 Helge Deller 2023-11-23 19:43:59 UTC
I've added a kernel patch to the for-next branch to remove those from parisc's errno.h file:
https://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux.git/log/?h=for-next
Comment 5 Bruno Haible 2023-11-23 19:56:09 UTC
(In reply to Helge Deller from comment #4)
> I've added a kernel patch to the for-next branch to remove those from
> parisc's errno.h file:

Thanks! That looks exactly like what is needed.