JKISoftware / JKI-State-Machine-Objects

Object-oriented framework for LabVIEW based on the JKI State Machine
BSD 3-Clause "New" or "Revised" License
95 stars 54 forks source link

Creation of shared dependencies by concurrent processes creates instance duplication #47

Closed francois-normandin closed 6 years ago

francois-normandin commented 6 years ago

This needs to be reproduced as it is supposed to be supported. Two subsystems that use a third subsystem as a dependency (ex: logger) can sometimes create two instances of the logger class instead of sharing a single instance. Instances are supposed to be shared if the instance name is identical and if the declared type matches. Hint to reproduce/identify this bug, look for different inheritance levels that do not resolve correctly or for a race condition in the registration of a new subsystem in the Registry class.

francois-normandin commented 6 years ago

image

Culprit is the onStart method which does not ensure that no race conditions can occur on concurrent processes creating shared dependencies. Time between the two arrows on the screenshot is enough to create a race condition.

francois-normandin commented 6 years ago

will be fixed in 1.3.0. [Fix: 47] LaunchDependency method, called during onStart, is split in two parts: one that creates the dependency and takes ownership on creation (in a non-reentrant method to disallow concurrent creations), the second to start the dependency which is reentrant to allow recursive calls.

francois-normandin commented 6 years ago

fixed in 1.3.0