CCTK_VInfo is not thread-safe
Issue #2326
open
CCTK_VInfo, CCTK_VWarn, and CCTK_VError use static variables. This is not thread-safe. These functions should be wrapped with an OpenMP critical pragma.
Comments (3)
-
-
- changed status to open
-
- marked as minor
Downgrading to minor since a well known workaround exists (see wiki for meaning of priorities) so does not need to be addressed before next release.
A proper fix should be applied to all Cactus API function and not just a few.
- Log in to comment
This is not only an issue for
CCTK_Warn
like functions. Right now nothing in Cactus is guaranteed to be thread safe, since even read only access to shared structures such as the list of warning callbacks or the list of Cactus timers would need protections since those structures can change at runtime.So far it has been the client code’s responsibility to wrap
CCTK_VWarn
and the like inomp critical
sections. This is useful in particular in Fortran code where multipleCCTK_Warn
are used to make up a single error message (and that message should show up as one block and not intermixed by other threads).This specific case of static variables is addressed in
#2322which is up for review. Even without static variables acritical
is a good idea b/c of the list of callbacks being traversed (it is dynamic) and there being multiplefprintf
calls in this function.