Skip to contentSkip to conversation

strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe

PATCH Superseded Florian Weimer 3 participants 13 messages Jul 13, 2023 – Aug 14, 2023 1 message not in the archive Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CAMO6KYomqkRFVnE1gfNa=htbZ5oBrVAm+AsFVqc6+vqZ0YxnAw@mail.gmail.com

#1 lore raw

* Shani Leviim:

Quoted 4 lines
(quoted diff) +0 -0
@@ -169,6 +172,16 @@ is too small and
 is unknown).
 The string always includes a terminating null byte (\(aq\e0\(aq).
 .\"

Review is too small and · line 184

Quoted 10 lines
(quoted diff) +10 -0
+.PP
+The automatically generated buffer for
+.BR strerror ()
+and
+.BR strerror_l ()
+is sufficient to avoid an
+.B ERANGE
+error when calling
+.BR strerror_r ().
+.PP

I think this gives the wrong impression that the pointer returned by strerror/strerror_l can be used with strerror_r. This is not the case because the application does not own that buffer, or know its length.

Thanks,
Florian

#2 lore raw

Thanks, Florian, for reviewing,
My original mail wasn't text plained, sorry for that.

The information in my patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead Following the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

man3/strerror.3 +0 -0
index 72b4d3994..31818e4ae 100644
@@ -91,11 +91,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be -modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
.BR strerror ()
or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
No other library function, including
.BR perror (3),
will modify this string.
@@ -120,12 +121,12 @@ For example, given
as an argument, this function returns a pointer to the string "EPERM". .\"
.SS strerror_r()
-The
.BR strerror_r ()
-function is similar to
+is like
.BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
This function is available in two versions:
an XSI-compliant version specified in POSIX.1-2001 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -249,7 +250,7 @@ l l l.
Interface Attribute Value
T{
.BR strerror ()

-T}     Thread safety   MT-Unsafe race:strerror
+T}     Thread safety   MT-Safe

T{
.BR strerrorname_np (),
.BR strerrordesc_np ()
@@ -260,6 +261,10 @@ T{
.BR strerror_l ()
T} Thread safety MT-Safe
.TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
.SH CONFORMING TO
.BR strerror ()
is specified by POSIX.1-2001, POSIX.1-2008, C89, and C99.
@@ -300,13 +305,6 @@ to
if the error number is unknown.
C99 and POSIX.1-2008 require the return value to be non-NULL. .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for -.BR strerror ().
-This buffer size therefore should be sufficient to avoid an -.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
.BR strerrorname_np ()
and
.BR strerrordesc_np ()
@@ -317,4 +315,5 @@ are thread-safe and async-signal-safe.
.BR error (3),
.BR perror (3),
.BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

Regards,
Shani Leviim

Regards,
Shani Leviim

Quoted 25 lines · Florian Weimer

* Shani Leviim:

Quoted 4 lines
(quoted diff) +0 -0
@@ -169,6 +172,16 @@ is too small and
 is unknown).
 The string always includes a terminating null byte (\(aq\e0\(aq).
 .\"

Review is too small and · line 184

Quoted 10 lines
(quoted diff) +10 -0
+.PP
+The automatically generated buffer for
+.BR strerror ()
+and
+.BR strerror_l ()
+is sufficient to avoid an
+.B ERANGE
+error when calling
+.BR strerror_r ().
+.PP

I think this gives the wrong impression that the pointer returned by strerror/strerror_l can be used with strerror_r. This is not the case because the application does not own that buffer, or know its length.

Thanks,
Florian

#3 lore raw

Hi all,
My previous patch wasn't aligned with the master branch. Here's the updated patch (compared to master):

man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be -modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
.BR strerror ()
or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
No other library function, including
.BR perror (3),
will modify this string.
@@ -100,12 +101,12 @@ For example, given
as an argument, this function returns a pointer to the string "EPERM". .\"
.SS strerror_r()
-The
.BR strerror_r ()
-function is similar to
+is like
.BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
This function is available in two versions:
an XSI-compliant version specified in POSIX.1-2001 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface Attribute Value
T{
.BR strerror ()
T} Thread safety T{
-MT-Unsafe race:strerror
+MT-Safe
T}
T{
.BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
.BR strerror_l ()
T} Thread safety MT-Safe
.TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
.hy
.ad
.sp 1
@@ -292,13 +297,6 @@ to
if the error number is unknown.
C99 and POSIX.1-2008 require the return value to be non-NULL. .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an -.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
.BR strerrorname_np ()
and
.BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
.BR error (3),
.BR perror (3),
.BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

Regards,
Shani Leviim

Quoted 124 lines · Shani Leviim

Thanks, Florian, for reviewing,
My original mail wasn't text plained, sorry for that.

The information in my patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead Following the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

man3/strerror.3 +0 -0
index 72b4d3994..31818e4ae 100644
@@ -91,11 +91,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +15 -16
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -120,12 +121,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -249,7 +250,7 @@ l l l.
 Interface      Attribute       Value
 T{
 .BR strerror ()
-T}     Thread safety   MT-Unsafe race:strerror
+T}     Thread safety   MT-Safe
 T{
 .BR strerrorname_np (),
 .BR strerrordesc_np ()
@@ -260,6 +261,10 @@ T{
 .BR strerror_l ()
 T}     Thread safety   MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .SH CONFORMING TO
 .BR strerror ()
 is specified by POSIX.1-2001, POSIX.1-2008, C89, and C99.
@@ -300,13 +305,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -317,4 +315,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

Regards,
Shani Leviim

Regards,
Shani Leviim

Quoted 25 lines · Florian Weimer

* Shani Leviim:

Quoted 4 lines
(quoted diff) +0 -0
@@ -169,6 +172,16 @@ is too small and
 is unknown).
 The string always includes a terminating null byte (\(aq\e0\(aq).
 .\"

Review is too small and · line 184

Quoted 10 lines
(quoted diff) +10 -0
+.PP
+The automatically generated buffer for
+.BR strerror ()
+and
+.BR strerror_l ()
+is sufficient to avoid an
+.B ERANGE
+error when calling
+.BR strerror_r ().
+.PP

I think this gives the wrong impression that the pointer returned by strerror/strerror_l can be used with strerror_r. This is not the case because the application does not own that buffer, or know its length.

Thanks,
Florian

#4 lore raw

Hi Shani, Florian,

Quoted 3 lines · Shani Leviim

Hi all,
My previous patch wasn't aligned with the master branch. Here's the updated patch (compared to master):

Thanks for the patch.

Florian, do you have any comments about this patch?

Quoted 82 lines
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +15 -16
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface   Attribute       Value
 T{
 .BR strerror ()
 T}     Thread safety   T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}     Thread safety   MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Quoted 1 line

Can you please include that information in the commit message itself? I suggest using git-format-patch(1) + git-send-email(1) to send the patch. If git-send-email(1) is not an option for you, then I suggest adding a copy of the patch as an attachment (but keep the inline copy please).

Check the ./CONTRIBUTING file.

Cheers,
Alex

Quoted 130 lines

Regards,
Shani Leviim

Quoted 124 lines · Shani Leviim

Thanks, Florian, for reviewing,
My original mail wasn't text plained, sorry for that.

The information in my patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead Following the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

man3/strerror.3 +0 -0
index 72b4d3994..31818e4ae 100644
@@ -91,11 +91,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +15 -16
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -120,12 +121,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -249,7 +250,7 @@ l l l.
 Interface      Attribute       Value
 T{
 .BR strerror ()
-T}     Thread safety   MT-Unsafe race:strerror
+T}     Thread safety   MT-Safe
 T{
 .BR strerrorname_np (),
 .BR strerrordesc_np ()
@@ -260,6 +261,10 @@ T{
 .BR strerror_l ()
 T}     Thread safety   MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .SH CONFORMING TO
 .BR strerror ()
 is specified by POSIX.1-2001, POSIX.1-2008, C89, and C99.
@@ -300,13 +305,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -317,4 +315,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

Regards,
Shani Leviim

Regards,
Shani Leviim

Quoted 25 lines · Florian Weimer

* Shani Leviim:

Quoted 4 lines
(quoted diff) +0 -0
@@ -169,6 +172,16 @@ is too small and
 is unknown).
 The string always includes a terminating null byte (\(aq\e0\(aq).
 .\"

Review is too small and · line 184

Quoted 10 lines
(quoted diff) +10 -0
+.PP
+The automatically generated buffer for
+.BR strerror ()
+and
+.BR strerror_l ()
+is sufficient to avoid an
+.B ERANGE
+error when calling
+.BR strerror_r ().
+.PP

I think this gives the wrong impression that the pointer returned by strerror/strerror_l can be used with strerror_r. This is not the case because the application does not own that buffer, or know its length.

Thanks,
Florian

Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
#5 lore raw

Thanks, Alex,
Attaching the patch (see attachments)

From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH 1/1] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be -modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
.BR strerror ()
or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
No other library function, including
.BR perror (3),
will modify this string.
@@ -100,12 +101,12 @@ For example, given
as an argument, this function returns a pointer to the string "EPERM". .\"
.SS strerror_r()
-The
.BR strerror_r ()
-function is similar to
+is like
.BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
This function is available in two versions:
an XSI-compliant version specified in POSIX.1-2001 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface Attribute Value
T{
.BR strerror ()
T} Thread safety T{
-MT-Unsafe race:strerror
+MT-Safe
T}
T{
.BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
.BR strerror_l ()
T} Thread safety MT-Safe
.TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
.hy
.ad
.sp 1
@@ -292,13 +297,6 @@ to
if the error number is unknown.
C99 and POSIX.1-2008 require the return value to be non-NULL. .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an -.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
.BR strerrorname_np ()
and
.BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
.BR error (3),
.BR perror (3),
.BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

Signature · 5 lines
2.39.3


Regards,
Shani Leviim
Quoted 232 lines · Alejandro Colomar

Hi Shani, Florian,

Quoted 3 lines · Shani Leviim

Hi all,
My previous patch wasn't aligned with the master branch. Here's the updated patch (compared to master):

Thanks for the patch.

Florian, do you have any comments about this patch?

Quoted 82 lines
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +15 -16
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface   Attribute       Value
 T{
 .BR strerror ()
 T}     Thread safety   T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}     Thread safety   MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Quoted 1 line

Can you please include that information in the commit message itself? I suggest using git-format-patch(1) + git-send-email(1) to send the patch. If git-send-email(1) is not an option for you, then I suggest adding a copy of the patch as an attachment (but keep the inline copy please).

Check the ./CONTRIBUTING file.

Cheers,
Alex

Quoted 126 lines

Regards,
Shani Leviim

Quoted 121 lines · Shani Leviim

Thanks, Florian, for reviewing,
My original mail wasn't text plained, sorry for that.

The information in my patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead Following the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

man3/strerror.3 +0 -0
index 72b4d3994..31818e4ae 100644
@@ -91,11 +91,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +15 -16
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -120,12 +121,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -249,7 +250,7 @@ l l l.
 Interface      Attribute       Value
 T{
 .BR strerror ()
-T}     Thread safety   MT-Unsafe race:strerror
+T}     Thread safety   MT-Safe
 T{
 .BR strerrorname_np (),
 .BR strerrordesc_np ()
@@ -260,6 +261,10 @@ T{
 .BR strerror_l ()
 T}     Thread safety   MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .SH CONFORMING TO
 .BR strerror ()
 is specified by POSIX.1-2001, POSIX.1-2008, C89, and C99.
@@ -300,13 +305,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -317,4 +315,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

Regards,
Shani Leviim

Regards,
Shani Leviim

Quoted 22 lines · Florian Weimer

* Shani Leviim:

Quoted 4 lines
(quoted diff) +0 -0
@@ -169,6 +172,16 @@ is too small and
 is unknown).
 The string always includes a terminating null byte (\(aq\e0\(aq).
 .\"

Review is too small and · line 184

Quoted 10 lines
(quoted diff) +10 -0
+.PP
+The automatically generated buffer for
+.BR strerror ()
+and
+.BR strerror_l ()
+is sufficient to avoid an
+.B ERANGE
+error when calling
+.BR strerror_r ().
+.PP

I think this gives the wrong impression that the pointer returned by strerror/strerror_l can be used with strerror_r. This is not the case because the application does not own that buffer, or know its length.

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

Thanks,
Florian

--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

From 387522bc37d492bfa8aa094b99c6d5f1131e3a4b Mon Sep 17 00:00:00 2001
From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH 1/1] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32,
strerror() is considered MT-Safe, and the man page should be changed accordingly.

---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +15 -16
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the appropriate language.
 is
 .BR EINVAL ,
 the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface	Attribute	Value
 T{
 .BR strerror ()
 T}	Thread safety	T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}	Thread safety	MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Signature · 1 line
2.39.3
#6 lore raw

Hi Shani,

Quoted 8 lines · Shani Leviim

Thanks, Alex,
Attaching the patch (see attachments)

From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH 1/1] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

Quoted 8 lines

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

The patch doesn't apply. Can you please check what's wrong with it?

$ git am patches/0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch
Applying: strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
error: patch failed: man3/strerror.3:238
error: man3/strerror.3: patch does not apply
Patch failed at 0001 strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Thanks,
Alex

Quoted 83 lines
---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +15 -16
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface    Attribute    Value
 T{
 .BR strerror ()
 T}    Thread safety    T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}    Thread safety    MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
#7 lore raw

Hi Alex,
I am re-attaching it.
I changed its name once it was created, so it may have caused an issue.

git apply --verbose 0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch Checking patch man3/strerror.3...
Applied patch man3/strerror.3 cleanly.

Sorry for the inconvenience

Regards,
Shani Leviim

Quoted 117 lines · Alejandro Colomar

Hi Shani,

Quoted 8 lines · Shani Leviim

Thanks, Alex,
Attaching the patch (see attachments)

From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH 1/1] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

Quoted 8 lines

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

The patch doesn't apply. Can you please check what's wrong with it?

$ git am patches/0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch
Applying: strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
error: patch failed: man3/strerror.3:238
error: man3/strerror.3: patch does not apply
Patch failed at 0001 strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Thanks,
Alex

Quoted 79 lines
---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +13 -15
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface    Attribute    Value
 T{
 .BR strerror ()
 T}    Thread safety    T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}    Thread safety    MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
Quoted 9 lines

man3/strerror.3 are thread-safe and async-signal-safe. · line 311

Quoted 4 lines
man3/strerror.3 +2 -1
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

From 387522bc37d492bfa8aa094b99c6d5f1131e3a4b Mon Sep 17 00:00:00 2001
From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32,
strerror() is considered MT-Safe, and the man page should be changed accordingly.

---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +15 -16
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the appropriate language.
 is
 .BR EINVAL ,
 the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface	Attribute	Value
 T{
 .BR strerror ()
 T}	Thread safety	T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}	Thread safety	MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Signature · 1 line
2.39.3
#8 lore raw
Quoted 10 lines · Shani Leviim

Hi Alex,
I am re-attaching it.
I changed its name once it was created, so it may have caused an issue.

git apply --verbose 0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch Checking patch man3/strerror.3...
Applied patch man3/strerror.3 cleanly.

Sorry for the inconvenience

No problem :)

However, it still doesn't apply to master. I see that it applies to somewhere between man-pages-6.03 and man-pages-6.04. Could you please rebase it to either a release tag or the master branch, or specify the base to which it applies?

Thanks,
Alex

Quoted 131 lines

Regards,
Shani Leviim

Quoted 125 lines · Alejandro Colomar

Hi Shani,

Quoted 8 lines · Shani Leviim

Thanks, Alex,
Attaching the patch (see attachments)

From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH 1/1] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

Quoted 8 lines

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

The patch doesn't apply. Can you please check what's wrong with it?

$ git am patches/0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch
Applying: strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
error: patch failed: man3/strerror.3:238
error: man3/strerror.3: patch does not apply
Patch failed at 0001 strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Thanks,
Alex

Quoted 77 lines
---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +13 -15
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface    Attribute    Value
 T{
 .BR strerror ()
 T}    Thread safety    T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}    Thread safety    MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()

man3/strerror.3 are thread-safe and async-signal-safe. · line 311

Quoted 6 lines
man3/strerror.3 +2 -1
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
#9 lore raw

That's very strange
Working on master, my HEAD commit is commit
60eb580d1e836977d57355b6519f32e37bdc3392.
I might be missing something.

Regards,
Shani Leviim

Quoted 163 lines · Alejandro Colomar
Quoted 10 lines · Shani Leviim

Hi Alex,
I am re-attaching it.
I changed its name once it was created, so it may have caused an issue.

git apply --verbose 0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch Checking patch man3/strerror.3...
Applied patch man3/strerror.3 cleanly.

Sorry for the inconvenience

No problem :)

However, it still doesn't apply to master. I see that it applies to somewhere between man-pages-6.03 and man-pages-6.04. Could you please rebase it to either a release tag or the master branch, or specify the base to which it applies?

Thanks,
Alex

Quoted 131 lines

Regards,
Shani Leviim

Quoted 125 lines · Alejandro Colomar

Hi Shani,

Quoted 8 lines · Shani Leviim

Thanks, Alex,
Attaching the patch (see attachments)

From: Shani Leviim <[email protected]>
Date: Sun, 30 Jul 2023 15:51:07 +0300
Subject: [PATCH 1/1] strerror.3: Change strerror() reference from MT-Unsafe to
MT-Safe

Quoted 8 lines

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32, strerror() is considered MT-Safe, and the man page should be changed accordingly.

The patch doesn't apply. Can you please check what's wrong with it?

$ git am patches/0001-strerror.3-Change-strerror-reference-from-MT-Unsafe-.patch
Applying: strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
error: patch failed: man3/strerror.3:238
error: man3/strerror.3: patch does not apply
Patch failed at 0001 strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Thanks,
Alex

Quoted 77 lines
---
 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +0 -0
index 862e153ee..6a3d83164 100644
@@ -71,11 +71,12 @@ part of the current locale to select the

appropriate language.
is
.BR EINVAL ,
the returned description will be "Invalid argument".)

man3/strerror.3 +13 -15
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -100,12 +101,12 @@ For example, given
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -238,7 +239,7 @@ Interface    Attribute    Value
 T{
 .BR strerror ()
 T}    Thread safety    T{
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .BR strerrorname_np (),
@@ -249,6 +250,10 @@ T{
 .BR strerror_l ()
 T}    Thread safety    MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .hy
 .ad
 .sp 1
@@ -292,13 +297,6 @@ to
 if the error number is unknown.
 C99 and POSIX.1-2008 require the return value to be non-NULL.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()

man3/strerror.3 are thread-safe and async-signal-safe. · line 311

Quoted 6 lines
man3/strerror.3 +2 -1
@@ -309,4 +307,5 @@ are thread-safe and async-signal-safe.
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)

--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

#10 lore raw
Quoted 4 lines · Shani Leviim

That's very strange
Working on master, my HEAD commit is commit
60eb580d1e836977d57355b6519f32e37bdc3392.
I might be missing something.

Indeed. That commit is somewhere between man-pages-6.02 and man-pages-6.03, around 600 commits and 8 months ago. A lot of things have changed since then. I released a few days ago man-pages-6.05.01. :)

Don't worry, I'll apply the patch there and rebase it to git HEAD.

Cheers,
Alex

Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
#11 lore raw

PATCH v2 1/1 strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe

In reply to a message not in the archive

From: Shani Leviim <[email protected]>

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32,
strerror() is considered MT-Safe, and the man page should be changed accordingly.

---

Hi Shani,

This is your patch rebased to the current git HEAD.

Cheers,
Alex

 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +15 -16
index 8b36d6487..73199ef85 100644
@@ -72,11 +72,12 @@ .SH DESCRIPTION
 is
 .BR EINVAL ,
 the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -101,12 +102,12 @@ .SH DESCRIPTION
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -231,7 +232,7 @@ .SH ATTRIBUTES
 T}	Thread safety	T{
 .na
 .nh
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .na
@@ -246,6 +247,10 @@ .SH ATTRIBUTES
 .BR strerror_l ()
 T}	Thread safety	MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .SH STANDARDS
 .TP
 .BR strerror ()
@@ -301,13 +306,6 @@ .SH HISTORY
 .BR strerrordesc_np ()
 glibc 2.32.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -318,4 +316,5 @@ .SH SEE ALSO
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Signature · 1 line
2.40.1
#12 lore raw

PATCH v3 1/1 strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe

In reply to a message not in the archive

From: Shani Leviim <[email protected]>

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32,
strerror() is considered MT-Safe, and the man page should be changed accordingly.

Cc Florian Weimer <[email protected]>
Cc Carlos O'Donell <[email protected]>
Cc Sergei Gromeniuk <[email protected]>
Cc Gobinda Das <[email protected]>

---

v3: Added the CCs from the original thread.

 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +15 -16
index 8b36d6487..73199ef85 100644
@@ -72,11 +72,12 @@ .SH DESCRIPTION
 is
 .BR EINVAL ,
 the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -101,12 +102,12 @@ .SH DESCRIPTION
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -231,7 +232,7 @@ .SH ATTRIBUTES
 T}	Thread safety	T{
 .na
 .nh
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .na
@@ -246,6 +247,10 @@ .SH ATTRIBUTES
 .BR strerror_l ()
 T}	Thread safety	MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .SH STANDARDS
 .TP
 .BR strerror ()
@@ -301,13 +306,6 @@ .SH HISTORY
 .BR strerrordesc_np ()
 glibc 2.32.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -318,4 +316,5 @@ .SH SEE ALSO
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Signature · 1 line
2.40.1
#13 lore raw
Quoted 8 lines · Alejandro Colomar

From: Shani Leviim <[email protected]>

The information in this patch was obtained from a glibc upstream patch, commit ID 28aff047818eb1726394296d27b9c7885340bead

According the patch above, for glibc versions >=2.32,
strerror() is considered MT-Safe, and the man page should be changed accordingly.

Quoted 7 lines
Cc Florian Weimer <[email protected]>
Cc Carlos O'Donell <[email protected]>
Cc Sergei Gromeniuk <[email protected]>
Cc Gobinda Das <[email protected]>

---

Patch applied.

Cheers,
Alex

Quoted 84 lines

v3: Added the CCs from the original thread.

 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
man3/strerror.3 +15 -16
index 8b36d6487..73199ef85 100644
@@ -72,11 +72,12 @@ .SH DESCRIPTION
 is
 .BR EINVAL ,
 the returned description will be "Invalid argument".)
-This string must not be modified by the application, but may be
-modified by a subsequent call to
+This string must not be modified by the application,
+and the returned pointer will be invalidated on a subsequent call to
 .BR strerror ()
 or
-.BR strerror_l ().
+.BR strerror_l (),
+or if the thread that obtained the string exits.
 No other library function, including
 .BR perror (3),
 will modify this string.
@@ -101,12 +102,12 @@ .SH DESCRIPTION
 as an argument, this function returns a pointer to the string "EPERM".
 .\"
 .SS strerror_r()
-The
 .BR strerror_r ()
-function is similar to
+is like
 .BR strerror (),
-but is
-thread safe.
+but might use the supplied buffer
+.I buf
+instead of allocating one internally.
 This function is available in two versions:
 an XSI-compliant version specified in POSIX.1-2001
 (available since glibc 2.3.4, but not POSIX-compliant until glibc 2.13),
@@ -231,7 +232,7 @@ .SH ATTRIBUTES
 T}	Thread safety	T{
 .na
 .nh
-MT-Unsafe race:strerror
+MT-Safe
 T}
 T{
 .na
@@ -246,6 +247,10 @@ .SH ATTRIBUTES
 .BR strerror_l ()
 T}	Thread safety	MT-Safe
 .TE
+.PP
+Before glibc 2.32,
+.BR strerror ()
+is not MT-Safe.
 .SH STANDARDS
 .TP
 .BR strerror ()
@@ -301,13 +306,6 @@ .SH HISTORY
 .BR strerrordesc_np ()
 glibc 2.32.
 .SH NOTES
-The GNU C Library uses a buffer of 1024 characters for
-.BR strerror ().
-This buffer size therefore should be sufficient to avoid an
-.B ERANGE
-error when calling
-.BR strerror_r ().
-.PP
 .BR strerrorname_np ()
 and
 .BR strerrordesc_np ()
@@ -318,4 +316,5 @@ .SH SEE ALSO
 .BR error (3),
 .BR perror (3),
 .BR strsignal (3),
-.BR locale (7)
+.BR locale (7),
+.BR signal-safety (7)
Signature · 2 lines
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5