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