Detect data races involving only atomic operations even when no critical sections are defined
-force-data-races
-force-data-races enforces detection of data races involving only
atomic operations even when no critical sections are defined.
By default, Bug Finder detects data races only if one or both operations accessing a
shared variable is nonatomic. You can explicitly enable detection of data races
involving only atomic operations. See Data race including
atomic operations. However, if you do not use critical sections at all in
your code, to avoid flagging too many operations, this kind of data race detection is
still disabled. To force detection of data races involving atomic operations only even
in the absence of critical sections, use the option
-force-data-races.
In this example, the variable sharedVar1 is shared between threads
with start functions thread1_main and thread2_main
but operations on sharedVar1 are not protected against concurrent
access. If you run Bug Finder with the option -checkers
data_race_all, you do not see a data race because the code does not use
critical sections at all. A critical section, for instance, would involve use of a
pthread_mutex_lock-pthread_mutex_unlock pair.
You also see a warning in the log:
Warning: Checker 'Data Race' is activated but no protection have been defined
Warning: Checker 'Data Race including atomic operations' is disabled because no critical sections, temporal exclusions or routines to disable/enable all interrupts have been defined.
| To force activation of this checker use option -force-data-races
To see data races despite the absence of critical sections, use the option
-force-data-races.
Bug Finder:
polyspace-bug-finder -checkers data_race_all -force-data-races
Bug Finder Server:
polyspace-bug-finder-server -checkers data_race_all -force-data-races
This option is not useful in a Polyspace as You Code analysis.