From: Martin Quinson Date: Wed, 26 Apr 2017 11:56:10 +0000 (+0200) Subject: comment++ on that code that I barely understand but exhibits bugs X-Git-Tag: v3.16~309 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6e3289e56fd7ab16327569a2f961006bd985c2f4?ds=inline comment++ on that code that I barely understand but exhibits bugs --- diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index f2a18a6240..3e0f707c0a 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -79,6 +79,8 @@ public: { // inspired from http://www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html if (process->refcount_.fetch_sub(1, std::memory_order_release) == 1) { + // Make sure that any changes done on other threads before their acquire are commited before our delete + // http://stackoverflow.com/questions/27751025/why-is-an-acquire-barrier-needed-before-deleting-the-data-in-an-atomically-refer std::atomic_thread_fence(std::memory_order_acquire); delete process; }