Skip to content

Detect calls of thread-unsafe functions as races #723

Closed
@sim642

Description

@sim642

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.


The following thread-unsafe functions remain to be added to libraryFunctions.ml:

  • ecvt()
  • ftw()
  • nftw()
  • setkey()
  • wcsrtombs()
  • wcstombs()
  • wctomb()

Originally posted by @karoliineh in #1079 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions