fix(darwin): pin main goroutine to OS thread 0 for VZ GUI#5036
Open
trodemaster wants to merge 1 commit into
Open
fix(darwin): pin main goroutine to OS thread 0 for VZ GUI#5036trodemaster wants to merge 1 commit into
trodemaster wants to merge 1 commit into
Conversation
VZVirtualMachineView requires GUI operations on the process main thread. The existing runtime.LockOSThread() in hostagentAction runs too late — Go's scheduler can migrate the main goroutine to a worker thread before cobra dispatches, causing SIGTRAP on macOS 26 when the VZ driver calls startVirtualMachineWindow. Add an init() that calls runtime.LockOSThread() before main() runs, ensuring the goroutine stays on thread 0 from process start. Fixes: lima-vm#4743
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.
VZVirtualMachineView requires GUI operations to run on the process main
thread. limactl already calls runtime.LockOSThread() in hostagentAction,
but that runs too late: by the time cobra dispatches the hostagent
subcommand, Go's scheduler has already migrated the main goroutine to a
worker thread. On macOS 26 this causes a SIGTRAP when the VZ driver calls
startVirtualMachineWindow.
Adding runtime.LockOSThread() to an init() function ensures the main
goroutine is pinned to thread 0 before main() runs. The build tag
restricts the file to darwin; Linux and Windows are unaffected.
Tested on macOS 26.5 (25F71), Apple Silicon, with Lima 2.1.2-beta.0:
fresh macOS 26 guest install from IPSW and start of an existing macOS 26
VM with video.display: default both complete without SIGTRAP.
Assisted-by: Commercial LLM tooling
Fixes #4743