fix: SIGBUS on Apple Silicon — ObjC block PAC re-signing (v0.19.2)#90
Merged
fix: SIGBUS on Apple Silicon — ObjC block PAC re-signing (v0.19.2)#90
Conversation
- core/backend_test.go: backend registry, provider selection tests - hal/backends_test.go: factory pattern, backend enumeration tests - hal/dx12/convert_test.go: DX12 format/blend conversion tests - hal/gles/convert_test.go: expanded GLES format conversion tests - hal/noop/noop_test.go: expanded noop backend tests with error handling - hal/software/software_test.go: expanded software backend tests - hal/vulkan/convert_test.go: expanded Vulkan format conversion tests
…ocks ObjC blocks were constructed with _NSConcreteStackBlock + flags=0, but allocated on the Go heap. When Metal calls Block_copy() on these blocks during addCompletedHandler:, ARM64e PAC re-signs the invoke pointer. Our ffi.NewCallback pointers are unsigned, so authentication fails, producing a corrupted pointer that causes SIGBUS when Metal's completion queue invokes the callback. Switch to _NSConcreteGlobalBlock + BLOCK_IS_GLOBAL (1<<28), which makes Block_copy() a complete no-op (no memmove, no PAC re-signing). Add blockPinRegistry (sync.Map) to keep block literals alive since global blocks are not copied by Metal. Remove stale runtime.KeepAlive(uintptr) calls that were no-ops (GC doesn't track uintptr as roots). Fixes #89
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
_NSConcreteStackBlockon Go heap → PAC re-signing failure). Switch to_NSConcreteGlobalBlock+BLOCK_IS_GLOBALflag, addblockPinRegistryfor GC safety, remove staleruntime.KeepAlive(uintptr)no-ops.codecov.ymlFixes #89
Test plan
GOOS=darwin GOARCH=arm64cross-compile cleanGOOS=darwin GOARCH=amd64cross-compile cleango test ./...)golangci-lint run)