Repository navigation
Fix the crash opening Settings → Second brain - #24
Merged
Merged
Conversation
BrainiumSetup.hasGit ran xcode-select the first time a view read it, and
Process.waitUntilExit() spins the main run loop while it waits. SwiftUI
then redrew the Second brain page mid-call, read hasGit again while its
dispatch_once was still running, and libdispatch trapped ("trying to lock
recursively").
- hasGit now checks for git on disk: DEVELOPER_DIR, the folder
xcode-select points at, the Command Line Tools, then Xcode.
- Every waitUntilExit() is replaced by Process.launchForBlockingWait(),
which waits on a semaphore signalled from the termination handler, so
no call that runs a tool on the main thread can re-enter SwiftUI.
- The Brainium CLI's stderr is drained on its own thread so a chatty run
can't stall on a full pipe.
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.
Clicking Second brain in the sidebar crashed Prism 1.5.0 (
EXC_BREAKPOINT, BUG IN CLIENT OF LIBDISPATCH: trying to lock recursively).Cause:
BrainiumSetup.hasGitis a lazystatic letthat ranxcode-select -pthe first time the Second brain page read it while drawing.Process.waitUntilExit()spins the main run loop while it waits, so SwiftUI redrew the page mid-call, readhasGitagain while itsdispatch_oncewas still running, and libdispatch trapped.Fix
hasGitchecks for git on disk (DEVELOPER_DIR, the folderxcode-selectpoints at, the Command Line Tools, Xcode) without running anything.Process.launchForBlockingWait()waits on a semaphore signalled by the termination handler. It replaces all fourwaitUntilExit()calls (Brainium setup, the Brainium CLI bridge, thepssnapshot, the self-updater), so none of them can re-enter SwiftUI when called on the main thread.Tested on macOS 27.2.1:
./build.shbuilds with no warnings. A probe drewSecondBrainSettingsViewin a window and forced 40 redraws while running tools on the main thread: no crash, andhasGitfound Xcode at its non-default path.Generated by Claude Code