analyzer
analyzer copied to clipboard
Detect calls of thread-unsafe functions as races
Under "Thread-safe functions" of pthreads man page, it says the following:
A thread-safe function is one that can be safely (i.e., it will deliver the same results regardless of whether it is) called from multiple threads at the same time. POSIX.1-2001 and POSIX.1-2008 require that all specified in the standard shall be thread-safe, except for following functions:
Then a list of possibly thread-unsafe functions follows.
We should consider calls to these functions (in place of global variables) and report racing calls (in place of accesses).
I was reminded of this when trying to figure out why chrony uses a global lock to protect what seems to be thread-local data manipulation. It doesn't call any functions from this list, but for completenes it would be nice to detect as well.
Related to a couple of *_unlocked functions from the list, turns out there are flockfile, ftrylockfile and funlockfile, which treat a FILE as a mutex. No idea, if anyone uses them, but I guess it wouldn't hurt to also consider those for mutual exclusion.
Related to a couple of
*_unlockedfunctions from the list, turns out there areflockfile,ftrylockfileandfunlockfile, which treat aFILEas a mutex. No idea, if anyone uses them, but I guess it wouldn't hurt to also consider those for mutual exclusion.
Should we move this to a new issue?