Skip to content

strerror is now thread safe#8648

Open
andrew-aitchison wants to merge 1 commit into
cppcheck-opensource:mainfrom
andrew-aitchison:strerror.is.thread.safe
Open

strerror is now thread safe#8648
andrew-aitchison wants to merge 1 commit into
cppcheck-opensource:mainfrom
andrew-aitchison:strerror.is.thread.safe

Conversation

@andrew-aitchison

Copy link
Copy Markdown
Contributor

Before glibc 2.32, strerror() is not MT-Safe.
(from man strerror on Ubuntu 26.04).

glibc 2.32 was released on 2020-08-05 and glibc 2.43 on 2026-01-24
(from https://sourceware.org/glibc/wiki/Glibc%20Timeline)

This patch stops the threadsafety.py addon from warning about strerror().

strerror was used in test/cli/other_test.py to test threadsafety.py so we also patch that to use a different thread-unsafe function.

@andrew-aitchison

Copy link
Copy Markdown
Contributor Author

I don't think the failing check reached my code. Can I run it again ?

@danmar

danmar commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

This page:
https://en.cppreference.com/c/string/byte/strerror

Says:
"strerror is not required to be thread-safe"

@andrew-aitchison

Copy link
Copy Markdown
Contributor Author

Hmm.
That is a change of spec since:
https://sourceforge.net/p/cppcheck/discussion/general/thread/209919289c/#2bf5

Spontanously I am skeptic about this warning. This warning will not age well if we keep it. In couple of years no recent distro will be unsafe.

How hard do we wish to work to avoid false-positives ?

I don't know whether other platforms have similar man-pages that could be used to generate a list for each platform. That might allow us to ship multiple lists and let the user select which ones they wish to be warned about ?

On the other hand; are how important is it to find POSIX issues as well C/C++ problems in user's code ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants