Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fixed a race condition in msg for communication between two processes. The
authorcasanova <casanova@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sun, 15 Feb 2009 18:46:07 +0000 (18:46 +0000)
committercasanova <casanova@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sun, 15 Feb 2009 18:46:07 +0000 (18:46 +0000)
commitb83dd387b08acb4e9cd4f9ea13e634b97e615133
tree0ae19d6b7167d8bc9df65e57239a6ab43932a843
parent21ad0e3da95c6efb3981d35e71b837735018b77c
Fixed a race condition in msg for communication between two processes. The
problem was with task->simdata->comm being used and then freed by the
receiver, and being used by the sender. The problem was that the sender
could be awakened after the receiver, and thus try to read de-allocated
memory.

The bug was fixed by adding a refcount field to task->simdata->comm, to ensure
that the freeing can be done by either the received and the sender, and always
by the last one to be awakened.  The refcount is initialized to 2, each process
reduces it by one, and the last one does the free. Setting the refcount to 2 is
a bit of a hack, but in the end seemed cleaner than sprinkling refcount++ and refcount--
all over the code, especially because this is already done for the refcount field
in task->simdata. Perhaps this refcount can be used for this purpose, but I
don't know enough about the innards of msg/simix to be 100% sure. This will
likely due for now, at least until the next rewrite ;)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6139 48e7efb5-ca39-0410-a469-dd3cf9ba447f
src/msg/msg_mailbox.c