From: Gabriel Corona Date: Fri, 19 Jun 2015 09:34:54 +0000 (+0200) Subject: Fix thread safety issue in process cleanup X-Git-Tag: v3_12~561 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/be00fecb16c89d44253052889f4815b35ab9abbe?hp=be00fecb16c89d44253052889f4815b35ab9abbe Fix thread safety issue in process cleanup While trying to find the root cause of the occasional failure of the kademlia test, I found a thread-safety issue here: When running in parallel mode all worker threads can call the `SIMIX_process_cleanup()` concurrently which does things such as: ~~~c++ XBT_DEBUG("%p should not be run anymore",process); xbt_swag_remove(process, simix_global->process_list); xbt_swag_remove(process, SIMIX_host_priv(process->smx_host)->process_list); xbt_swag_insert(process, simix_global->process_to_destroy); ~~~ The SWAG are modified concurrently by the worker threads without synchronization. Sometimes, they go into inconsistent states (for example, `swag->count` is no more consistent with the number of elements really in the swag). This fix might not be the best way to do it. ---