Repository navigation
timesync: fix _blocking data race, reject sync/async handler switch after lifecycle start - #453
Conversation
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
a243258 to
905a8d6
Compare
Agreed!
I think we can safely disallow switching the SimStep modes while the simulation is running. This won't prevent any meaningful scenario. The only case it would prevent is one where you need the "implicit queueing" of the normal SimStepHandler at some points in the simulation and the "ping-pong within a step" of the AsyncSimStep at others. How relevant that use case is remains questionable, though. |
Maybe it's more clear to allow switching only before the call to StartLifecylce(). Otherwise we would still allow to switch in the |
Agreed, this is more straightforward. I also noticed that checking for |
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
bc2ea28 to
ae343ef
Compare
_blocking data race, reject sync/async handler switch at runtime_blocking data race, reject sync/async handler switch after lifecycle start
Signed-off-by: Maximilian Fricke <maximilian.fricke@synopsys.com>
KonradBreitsprecherBkd
left a comment
There was a problem hiding this comment.
Looks good, no issues.
Description
Follow-up to #352 with two independent changes:
Protect
TimeConfiguration::_blockingwith the mutex.Re-registering the async step handler from a user thread while the step is still open (the supported way to change the step size) races with
ExecuteSimStep(), which reads the flag after the handler returned.See 367811e for a reproducer. It passes in a normal build and is reported by TSan without this fix.
Reject switching between
SetSimulationStepHandlerandSetSimulationStepHandlerAsynconce the participant isRunning(SilKit::StateError).Switching before
Runningand re-registering a handler of the same kind at any time (e.g. to change the step size) is still allowed.Why: the mutex from 1. does not make the switch safe, a single step still reads the flag several times (
IsBlocking(),IsSimStepSync()) and can see different values.CompleteSimulationStep(), a switch to sync makes the nextNextSimTasktakeAdvanceTimeSimStepSync(), which, unlikeAdvanceTimeSimStepAsync(), does not check_isExecutingSimStep.See temporary commit a908a6a for reproducers.
ExecuteSimStep(), staleEvaluateAggregationInfo()results.Rejecting this technically breaks compatibility, though I think it is unlikely that users switch between sync/async handlers at runtime. However, since re-registration is the advertised API for changing the step size, this became somewhat more prominent.
I think 1. is straightforward, 2. may need discussion. An alternative to rejecting may be to guard
AdvanceTimeSimStepSync()with_isExecutingSimStepand fix metrics/aggregation separately.Developer checklist (address before review)