Menu

#552 fix(capture): stop an a11y observer double-free crash on capture restart

closed
nobody
None
2026-07-22
2026-07-22
Anonymous
No

Originally created by: adityaharishch

Summary

  • Root-caused 8 SIGABRT crash reports on shipped v1.74.0 (BUG_IN_CLIENT_OF_LIBMALLOC_POINTER_BEING_FREED_WAS_NOT_ALLOCATED inside screenpipe_a11y::run_app_observer's NotificationGuard teardown, removeObserver:CFXNotificationRegistrarRemoveToken_Block_release).
  • Cause: start_capture (tray/src-tauri/src/lib.rs) signalled the old UI-event recorder to stop and immediately spawned its replacement, without waiting for the old recorder's OS thread to actually exit. That thread only notices the stop signal on its own ~500ms poll, so for a window after every restart (pause/resume, launch) two threads held live NotificationGuards against the same shared NSWorkspace notification center at once — racing its block-based observer teardown.
  • Two-sided fix:
  • Meridiona/screenpipe-fork (pushed to main, rev 3c99154): added a process-wide WORKSPACE_OBSERVER_LOCK held for the whole run_app_observer call, so at most one thread ever touches the shared center regardless of how a caller sequences start/stop. This repo's pinned screenpipe-a11y/screenpipe-screen rev is bumped to pick it up.
  • Here: AppState now keeps the UI-event recorder's JoinHandle; start_capture joins it before spawning the replacement, closing the race at the source rather than relying only on the fork's defense-in-depth lock.

Test plan

  • [x] cargo fmt --check / cargo clippy -- -D warnings (capture feature) — clean
  • [x] cargo test --features capture — 151 passed
  • [x] Full pre-push suite (fmt + clippy + UI build/tests + security audit + cargo test) — all green
  • [ ] Manual: exercise pause → resume repeatedly on Apple Silicon and confirm no crash reports over an extended session

Related

Tickets: #554
Tickets: #555

Discussion

  • Anonymous

    Anonymous - 2026-07-22

    Originally posted by: coderabbitai[bot]

    [!IMPORTANT]

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.


    ⚙️ Run configuration

    Configuration used: Organization UI

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: 5457d526-ae04-4802-bf3d-6fb0c18f9b82

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:
    - [ ] 🔍 Trigger review

    ✨ Finishing Touches
    🧪 Generate unit tests (beta) - [ ] Create PR with unit tests - [ ] Commit unit tests in branch `fix/capture-observer-teardown-race`

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

    Comment @coderabbitai help to get the list of available commands.

     
  • Anonymous

    Anonymous - 2026-07-22

    Ticket changed by: adityaharishch

    • status: open --> closed
     

Log in to post a comment.