On Ubuntu 25-04 (Plucky) man ctime says (in the attributes table):
Interface
Attribute
Value
ctime()
Thread safety
MT-Unsafe race:tmbuf race:asctime env locale
(see man 7 attributes for the detaiila of the terms used).
so this is an edge case, but it is not obvious to me that it is a false-positive - what do others think ?
Background
The list of MT-unsafe functions in the threadsafety addon is computer-generated by tools/MT-Unsafe.py which reads the attributes table of man pages. We could ignore race conditions highlighted in this table if you think these are false positives, or we could specifically exclude ctime().
Bear in mind that a function can could be thread safe on one platform but unsafe on another and may change over time eg man strerror on my machines says:
Before glibc 2.32, strerror() is not MT-Safe. https://sourceforge.net/p/cppcheck/discussion/general/thread/209919289c/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In that case it is definitely a bug in addons/threadsafety.py
I note that cppcheck --enable=warning --addon=y2038.py test/main.c
gives similar false positives.
I copied this feature from y2038.py to threadsafety.py but I don't think my python is up to fixing this.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
cppcheck 2.18.0 generates threadsafety-unsafe-call false positive for the following code:
threadsafety-unsafe-call
seems to be a cppcheck Premium feature, so you should report the bug here: https://www.cppcheck.com/I used open source cppcheck 2.18.0 with --addon=threadsafety.py arg.
I see, didn't realize that this addon existed.
On Ubuntu 25-04 (Plucky) man ctime says (in the attributes table):
(see man 7 attributes for the detaiila of the terms used).
so this is an edge case, but it is not obvious to me that it is a false-positive - what do others think ?
Background
The list of MT-unsafe functions in the threadsafety addon is computer-generated by
tools/MT-Unsafe.py
which reads the attributes table of man pages. We could ignore race conditions highlighted in this table if you think these are false positives, or we could specifically exclude ctime().Bear in mind that a function can could be thread safe on one platform but unsafe on another and may change over time eg
man strerror
on my machines says:Before glibc 2.32, strerror() is not MT-Safe.
https://sourceforge.net/p/cppcheck/discussion/general/thread/209919289c/
The original code does not reference
ctime()
at all.In that case it is definitely a bug in addons/threadsafety.py
I note that
cppcheck --enable=warning --addon=y2038.py test/main.c
gives similar false positives.
I copied this feature from y2038.py to threadsafety.py but I don't think my python is up to fixing this.