Repository navigation
Fix crash on New Project while master effects ring - #21
Merged
Merged
Conversation
… them A project load replaced the master's effect chain by freeing the old effects in place. When the old project was still ringing, the engine's fading adoption renders the old chain for one more chunk, and the audio thread read the freed states (segfault in adoptAssets on New Project). The load now removes them through Track.removeEffect, so they retire and free only after audio adopts the new chain, and the UI loop collects the master's retired machines every frame like the tracks'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The crash
Pressing New Project, or opening another project, while the current project's master effects were still sounding could segfault on the audio thread:
It reproduced after playing a song with a long
verb2cathedral tail and a masterlimiter2, then pressing New Project.Cause
document.applyreplaced the master's effect chain by callingdeiniton the old effects in place. Every other path (removeEffect,replaceEffect,replaceMachine) hands old machines toretired_machines, which frees them only after the audio thread acknowledges the new chain. Regular tracks don't hit this because they're replaced whole while the device is stopped. The master is restored in place.When the engine is still ringing at restart,
Track.adoptMachines(fade=true)keeps the old chain for one more fade-out chunk. SoadoptTrackcalledadopt_updateson the freed effect states.Fix
document.applynow removes the master's effects withTrack.removeEffect, so they retire like any other removed effect.publishSnapshot. The old chain's memory is freed as soon as audio moves past it, not at the next master edit.Verification
realtime: a project load retires the master's effects until audio adopts the new chain, fails before the fix (the effect is freed while the audio side still holds it) and passes after. It covers the fading adoption, the switch, and the free afterwards.zig build testpasses.zig build bench -- --all --check --no-sheetsis bit-exact on all 164 golden cases.🤖 Generated with Claude Code