CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
56 lines
1.9 KiB
ReStructuredText
56 lines
1.9 KiB
ReStructuredText
.. title:: clang-tidy - concurrency-mt-unsafe
|
|
|
|
concurrency-mt-unsafe
|
|
=====================
|
|
|
|
Checks for some thread-unsafe functions against a black list of
|
|
known-to-be-unsafe functions. Usually they access static variables without
|
|
synchronization (e.g. gmtime(3)) or utilize signals in a racy way.
|
|
The set of functions to check is specified with the `FunctionSet` option.
|
|
|
|
Note that using some thread-unsafe functions may be still valid in
|
|
concurrent programming if only a single thread is used (e.g. setenv(3)),
|
|
however, some functions may track a state in global variables which
|
|
would be clobbered by subsequent (non-parallel, but concurrent) calls to
|
|
a related function. E.g. the following code suffers from unprotected
|
|
accesses to a global state:
|
|
|
|
.. code-block:: c++
|
|
|
|
// getnetent(3) maintains global state with DB connection, etc.
|
|
// If a concurrent green thread calls getnetent(3), the global state is corrupted.
|
|
netent = getnetent();
|
|
yield();
|
|
netent = getnetent();
|
|
|
|
|
|
Examples:
|
|
|
|
.. code-block:: c++
|
|
|
|
tm = gmtime(timep); // uses a global buffer
|
|
|
|
sleep(1); // implementation may use SIGALRM
|
|
|
|
Options
|
|
-------
|
|
|
|
.. option:: FunctionSet
|
|
|
|
Specifies which functions in libc should be considered thread-safe,
|
|
possible values are `posix`, `glibc`, or `any`.
|
|
|
|
`posix` means POSIX defined thread-unsafe functions. POSIX.1-2001
|
|
in "2.9.1 Thread-Safety" defines that all functions specified in the
|
|
standard are thread-safe except a predefined list of thread-unsafe
|
|
functions.
|
|
|
|
Glibc defines some of them as thread-safe (e.g. dirname(3)), but adds
|
|
non-POSIX thread-unsafe ones (e.g. getopt_long(3)). Glibc's list is
|
|
compiled from GNU web documentation with a search for MT-Safe tag:
|
|
https://www.gnu.org/software/libc/manual/html_node/POSIX-Safety-Concepts.html
|
|
|
|
If you want to identify thread-unsafe API for at least one libc or
|
|
unsure which libc will be used, use `any` (default).
|
|
|