Skip to content

Fix save overlap dangling reference - #15

Merged
ScepticalRabbit merged 2 commits into
mainfrom
fix_save_overlap_dangling_reference
Jul 21, 2026
Merged

Fix save overlap dangling reference#15
ScepticalRabbit merged 2 commits into
mainfrom
fix_save_overlap_dangling_reference

Conversation

@james-panayis

Copy link
Copy Markdown
Collaborator

Fix disk-save overlap coordinator lifetime

Summary

Fixes a lifetime bug where the background save worker received a pointer to coordinator state embedded in a SaveOverlap value that was subsequently moved. The coordinator now uses stable heap storage with ordered initialization rollback and teardown.

The change also synchronizes save-worker error reads and returns acquired slots to the pool when rasterization or publication fails.

Testing

Confirmed in Debug and ReleaseSafe:

  • Multicamera memory output matches .both.
  • Disk saving without overlap passes.
  • Disk saving with overlap completes and passes under a 30-second external timeout.

Before this fix, the overlap regression hung until the timeout exited with code 124.

CI follow-up

Once #11, which adds CI, is merged, the disk-save overlap test should be added to CI with an external timeout so future deadlocks fail deterministically. eg zig test -O ReleaseSafe src/test_gold_all.zig --test-filter "disk save with overlap" --test-cmd timeout --test-cmd 30s --test-cmd-bin

Run with `zig test src/test_gold_all.zig --test-filter "disk save with overlap" --test-cmd timeout --test-cmd 30s --test-cmd-bin` because the issue causes the code to hang
Also Heap-allocate shared state and harden cleanup, synchronization, and slot-release paths
@ScepticalRabbit
ScepticalRabbit merged commit 990f961 into main Jul 21, 2026
@james-panayis
james-panayis deleted the fix_save_overlap_dangling_reference branch August 6, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants