JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 28.0w | AdaCore Inc |
A warning of this class is issued when a worker thread may call one of the following functions:
Windows mutex, semaphore, and event creation calls, sem_open, semOpen, and the CMutex constructor are reported even if they open an existing named object. The check does not inspect the name or return value to distinguish creation from opening. Other calls that open or operate on existing objects, attribute initialization, and static initializers are not covered.
The check includes calls made through helper functions. Calls made only by the initial thread are not reported.
This check does not determine whether the initialization is safe or whether another thread accesses the object before it is initialized.
| Class Name | Synchronization Object Initialized in Worker Thread | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Significance | reliability | |||||||||
| Mnemonic | CONCURRENCY.C_THREAD.SYNCINIT | |||||||||
| Categories |
|
|||||||||
| Availability | Available for C and C++. | |||||||||
| Enabling | Checks for this warning class are
disabled by default. To enable them, add the following WARNING_FILTER
rule to the project configuration file.
WARNING_FILTER += allow class="Synchronization Object Initialized in Worker Thread" |
#include <threads.h>
#include <stdlib.h>
static mtx_t queue_mutex;
static int service_worker(void *) {
return mtx_init(&queue_mutex, mtx_plain); // 'Synchronization Object Initialized in Worker Thread' warning issued here
}
int main() {
thrd_t service;
if (thrd_create(&service, service_worker, 0) != thrd_success)
abort();
if (thrd_join(service, 0) != thrd_success)
abort();
return 0;
}
To reproduce this example, analyze it with the following configuration:
WARNING_FILTER += allow class="Synchronization Object Initialized in Worker Thread"
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.adacore.com/csm.