CCTK_VInfo is not thread-safe

Issue #2326 open
Erik Schnetter created an issue

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)

  1. Roland Haas

    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 in omp critical sections. This is useful in particular in Fortran code where multiple CCTK_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 #2322 which is up for review. Even without static variables a critical is a good idea b/c of the list of callbacks being traversed (it is dynamic) and there being multiple fprintf calls in this function.

  2. Roland Haas

    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.

  3. Log in to comment