Skip to content

Commit 3494c40

Browse files
authored
Merge pull request #76399 from al45tair/eng/PR-135787913
[Backtracer][macOS] Fix crashing thread index when Rosetta is in use.
2 parents 938d659 + 4c47540 commit 3494c40

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stdlib/public/libexec/swift-backtrace/TargetMacOS.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,12 @@ class Target {
249249

250250
if info.thread_id == crashingThread {
251251
ctx = HostContext.fromHostMContext(mcontext)
252-
crashingThreadNdx = Int(ndx)
252+
crashingThreadNdx = threads.count
253253
} else {
254254
guard let threadCtx = HostContext.fromHostThread(ports[Int(ndx)]) else {
255255
// This can happen legitimately, e.g. when looking at a Rosetta 2
256256
// process, where there are ARM64 threads AS WELL AS the x86_64 ones.
257+
mach_port_deallocate(mach_task_self_, ports[Int(ndx)])
257258
continue
258259
}
259260
ctx = threadCtx

0 commit comments

Comments
 (0)