Mantis - Croquet
Viewing Issue Advanced Details
5709 Hedgehog minor random 01-07-07 21:40 02-01-07 04:17
0005709: FarRefMap not thread-safe
I sometimes get errors within FarRefMap operations like #growTo:, where indexes aren't valid any more.

Island exports is a FarRefMap which contains a weak array, and has several operations that are written assuming that they will be atomic with respect to changes in that array.
I have only observed this problem with KCroquetParticipant, which uses quite a few asynchronous processes in addition to the ones used by other CroquetParticipants. (Decoding of streaming media, EmbeddedApp updates, asynchrounous sync'ing of new islands...) It could be that these are broken. Or it could be that I only see this in KCroquetParticipant because it's the only Participant that I leave running for several days. (Other bugs like 5695 and 5708 keep other Participants from running with user interaction for that long.)

The attached changeset adds a mutex to FarRefMap, which is used by all the operations that might be so affected. This is not in a K...-specific subclass because Island default needs the mutex, too.

It might be a good idea to instument the mutex locking to see what processes are interfering with each other. I haven't had time to do that yet, but I wanted to report this in case anyone else was struggling with the same problem.
related to 0005722new  Transcript usage can cause undesireable interleavings 
 ThreadSafeFarRefMap.3.cs.gz [^] (1,181 bytes) 01-07-07 21:40

01-13-07 20:20   
In Islands-ar.40, Andreas noticed and removed a transcript send from FarRefMap>>findElementOrFlag:. It's possible that this simple change will fix the problem, per [^]
But it's not easy to test positively...
01-14-07 17:11   
I got the error again after using Islands-ar.40 and not using ThreadSafeFarRefMap.3.cs.
This was on a headless FreeBSD after six hours of being connected overnight over WAN to a Mac and a Windows participant.
02-01-07 04:17   
The ThreadSafeFarRefMap changeset is incorporated into Islands-ar.41.mcz in the repository.