Repository navigation
timesync: fix _blocking data race, reject sync/async handler switch at runtime - #453
Open
snps-fricke wants to merge 5 commits into
Open
snps-fricke wants to merge 5 commits into
snps-fricke wants to merge 5 commits into
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>
snps-fricke
force-pushed
the
dev/step_handler_registration_race
branch
from
October 28, 2026 14:24
a243258 to
905a8d6
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)