Repository navigation
core: world_clock_binding is thread-safe - #640
Merged
Merged
Conversation
The binding's own state (the pending single steps, the last step counter seen, the requested mode and pause) was unguarded. world_clock locks itself and the state tree is thread-safe, but request_steps() or pending_steps() from a UI thread while the frame thread ran drive() was a data race. The nav examples' step buttons and Ariadne host verbs call request_steps() that way. Every public call now takes a mutex. drive() holds it across pull, advance, the requested steps and push, so the result it returns, which splices two advances, is never interleaved with another drive(). Test: ClockBindingTakesStepRequestsFromAnyThread. Four threads request 1000 single steps while a fifth drives; every request runs exactly once.
transfix
added a commit
that referenced
this pull request
Oct 17, 2026
Minor release. It carries: - the world clock: lockstep and batch, followers, the sim.* binding, and nav on the clock (#629, #630, #631, #640); - the units registry with SI <-> normalized-frame conversions (#632); - cvc::physics with the Jolt backend (#641); - the material trainer on the kinematic bicycle and its pycvc bindings (#642). Bumps project(VERSION) 3.5.1 -> 3.6.0 and every cvcpkg recipe's upstream_version to match. cvc_revision stays 1, per the recipe-version gate.
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.
Why
world_clocklocks itself and the state tree is thread-safe, butworld_clock_binding's own members were not guarded:Calling
request_steps()orpending_steps()from a UI thread while the frame thread runsdrive()was a data race. The nav examples' step buttons and Ariadne host verbs callrequest_steps()that way.What
pull,push,drive,request_steps,pending_steps) takes a mutex.drive()holds the lock across pull, advance, the requested steps and push. The step result it returns splices two advances, so it is never interleaved with anotherdrive().Verification (Windows, MSVC 2022, local cvcpkg prefix)
AppTest.ClockBindingTakesStepRequestsFromAnyThread: four threads request 1000 single steps while a fifth drives, and every request runs exactly once. It passed 4 runs in a row.app_test86/86,world_clock_test49/49, and pycvctest_pycvc_world_clock.pypass.