This project has moved. For the latest updates, please go here.


multiple race conditions in Messenger using recipients collections


examples of places (in Messenger.cs) contains potential race conditions using Messenger's _recipientsOfSubclassesAction and _recipientsStrictAction dictionaries:
  1. in method Register() dictionaries are growing not locked with same lock objects as in method Unregister() where they are shrinked. this may result in exceptions or invalid data if executes concurrently
  2. in methods UnregisterFromLists() and SendToTargetOrType() dictionary's method ContainsKey() are called without any locking. result of this call are useless whithout synchronization (dictionary may be modified right after this call and before using result of this call)
  3. in many methods dictionaries are being enumerated using Take() or ToList() methods without any locking. enumerating through a collection is intrinsically not a thread-safe procedure
any use of Messenger's _recipientsOfSubclassesAction and _recipientsStrictAction dictionaries should be synchronized (guarded by lock on same object). not only modification, but any use
Closed Oct 13, 2014 at 12:54 PM by lbugnion