All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: linux-man@vger.kernel.org
Cc: Alejandro Colomar <alx@kernel.org>,
	Shani Leviim <sleviim@redhat.com>,
	Florian Weimer <fweimer@redhat.com>,
	Carlos O'Donell <carlos@redhat.com>,
	Sergei Gromeniuk <sgromeni@redhat.com>,
	Gobinda Das <godas@redhat.com>
Subject: [PATCH v3] strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe
Date: Sun, 13 Aug 2023 22:21:33 +0200	[thread overview]
Message-ID: <20230813202132.55879-1-alx@kernel.org> (raw)
In-Reply-To: <CAMO6KYomqkRFVnE1gfNa=htbZ5oBrVAm+AsFVqc6+vqZ0YxnAw@mail.gmail.com>

From: Shani Leviim <sleviim@redhat.com>

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.

Signed-off-by: Shani Leviim <sleviim@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Sergei Gromeniuk <sgromeni@redhat.com>
Cc: Gobinda Das <godas@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---

v3: Added the CCs from the original thread.

 man3/strerror.3 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/man3/strerror.3 b/man3/strerror.3
index 8b36d6487..73199ef85 100644
--- a/man3/strerror.3
+++ b/man3/strerror.3
@@ -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)
-- 
2.40.1


  parent reply	other threads:[~2023-08-13 20:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAMO6KYomqkRFVnE1gfNa=htbZ5oBrVAm+AsFVqc6+vqZ0YxnAw@mail.gmail.com>
2023-07-13  8:12 ` [patch] strerror.3: Change strerror() reference from MT-Unsafe to MT-Safe Florian Weimer
2023-07-13 11:15   ` Shani Leviim
2023-07-16 17:28     ` Shani Leviim
2023-07-28 18:55       ` Alejandro Colomar
2023-07-30 13:41         ` Shani Leviim
2023-08-11 22:51           ` Alejandro Colomar
2023-08-13 14:37             ` Shani Leviim
2023-08-13 15:11               ` Alejandro Colomar
2023-08-13 16:58                 ` Shani Leviim
2023-08-13 20:06                   ` Alejandro Colomar
2023-08-13 20:19 ` [PATCH v2] " Alejandro Colomar
2023-08-13 20:21 ` Alejandro Colomar [this message]
2023-08-14 10:44   ` [PATCH v3] " Alejandro Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230813202132.55879-1-alx@kernel.org \
    --to=alx@kernel.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=godas@redhat.com \
    --cc=linux-man@vger.kernel.org \
    --cc=sgromeni@redhat.com \
    --cc=sleviim@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.