【发现一个问题】go test的时候,在macos arm64 下不明原因的发生异常,但是在linux下完全正常
作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢!
这只是一个简单的队列,在单个协程中运行,莫名其妙就 panic 了,而且堆栈信息中找不到有用信息。
同样的程序在 linux 中执行又是对的。
暂时想不明白是为什么。
Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^Test_SpscQueue_With_diff_size$ github.com/ahfuzhang/spscqueue === RUN Test_SpscQueue_With_diff_size unexpected fault address 0x140000d700e fatal error: fault [signal SIGBUS: bus error code=0x1 addr=0x140000d700e pc=0x100e898e0] goroutine 6 gp=0x14000003dc0 m=0 mp=0x100fd9c20 [running]: runtime.throw({0x100e92d5d?, 0x69?}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/panic.go:1023 +0x40 fp=0x140000565e0 sp=0x140000565b0 pc=0x100dc2230 runtime.sigpanic() /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/signal_unix.go:878 +0x178 fp=0x14000056640 sp=0x140000565e0 pc=0x100ddae98 github.com/ahfuzhang/spscqueue.(*SpscQueue).Alloc(0x2007?, 0xed6220?) /code/github.com/ahfuzhang/spscqueue/spsc_queue.go:287 +0x1c0 fp=0x14000056670 sp=0x14000056650 pc=0x100e898e0 github.com/ahfuzhang/spscqueue.oneByOneTest({0x100f02030, 0x140000d6000}, 0x1) /code/github.com/ahfuzhang/spscqueue/spsc_queue_test.go:672 +0x5c fp=0x140000566d0 sp=0x14000056670 pc=0x100e8f7ac github.com/ahfuzhang/spscqueue.Test_SpscQueue_With_diff_size(0x1400009e680) /code/github.com/ahfuzhang/spscqueue/spsc_queue_test.go:721 +0xf8 fp=0x14000056760 sp=0x140000566d0 pc=0x100e8fa48 testing.tRunner(0x1400009e680, 0x100effaa0) /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:1689 +0xec fp=0x140000567b0 sp=0x14000056760 pc=0x100e504fc testing.(*T).Run.gowrap1() /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:1742 +0x2c fp=0x140000567d0 sp=0x140000567b0 pc=0x100e5134c runtime.goexit({}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140000567d0 sp=0x140000567d0 pc=0x100dfb534 created by testing.(*T).Run in goroutine 1 /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:1742 +0x318 goroutine 1 gp=0x140000021c0 m=nil [chan receive]: runtime.gopark(0x140000c59c8?, 0x1400009cdd0?, 0x58?, 0xce?, 0x1400009cdd0?) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:402 +0xc8 fp=0x140000c5990 sp=0x140000c5970 pc=0x100dc5088 runtime.chanrecv(0x140000880e0, 0x140000c5a8f, 0x1) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/chan.go:583 +0x404 fp=0x140000c5a10 sp=0x140000c5990 pc=0x100d908c4 runtime.chanrecv1(0x100fd8f20?, 0x100ed61a0?) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/chan.go:442 +0x14 fp=0x140000c5a40 sp=0x140000c5a10 pc=0x100d904b4 testing.(*T).Run(0x1400009e4e0, {0x100e98cf6?, 0x140000c5b38?}, 0x100effaa0) /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:1750 +0x32c fp=0x140000c5b00 sp=0x140000c5a40 pc=0x100e5121c testing.runTests.func1(0x1400009e4e0) /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:2161 +0x40 fp=0x140000c5b40 sp=0x140000c5b00 pc=0x100e52ff0 testing.tRunner(0x1400009e4e0, 0x140000c5c58) /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:1689 +0xec fp=0x140000c5b90 sp=0x140000c5b40 pc=0x100e504fc testing.runTests(0x1400000e030, {0x100fc1f00, 0xd, 0xd}, {0x1400006bd18?, 0x100e3ea80?, 0x100fd9100?}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:2159 +0x3b0 fp=0x140000c5c80 sp=0x140000c5b90 pc=0x100e52ef0 testing.(*M).Run(0x140000961e0) /opt/homebrew/Cellar/go/1.22.0/libexec/src/testing/testing.go:2027 +0x5a4 fp=0x140000c5eb0 sp=0x140000c5c80 pc=0x100e51c24 main.main() _testmain.go:71 +0x16c fp=0x140000c5f40 sp=0x140000c5eb0 pc=0x100e91aec runtime.main() /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:271 +0x28c fp=0x140000c5fd0 sp=0x140000c5f40 pc=0x100dc4c2c runtime.goexit({}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140000c5fd0 sp=0x140000c5fd0 pc=0x100dfb534 goroutine 2 gp=0x14000002c40 m=nil [force gc (idle)]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:402 +0xc8 fp=0x14000054f90 sp=0x14000054f70 pc=0x100dc5088 runtime.goparkunlock(...) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:408 runtime.forcegchelper() /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:326 +0xb8 fp=0x14000054fd0 sp=0x14000054f90 pc=0x100dc4ee8 runtime.goexit({}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x14000054fd0 sp=0x14000054fd0 pc=0x100dfb534 created by runtime.init.6 in goroutine 1 /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:314 +0x24 goroutine 3 gp=0x14000003500 m=nil [GC sweep wait]: runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:402 +0xc8 fp=0x14000055760 sp=0x14000055740 pc=0x100dc5088 runtime.goparkunlock(...) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:408 runtime.bgsweep(0x14000088000) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgcsweep.go:278 +0xa0 fp=0x140000557b0 sp=0x14000055760 pc=0x100dafa30 runtime.gcenable.gowrap1() /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgc.go:203 +0x28 fp=0x140000557d0 sp=0x140000557b0 pc=0x100da3c58 runtime.goexit({}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140000557d0 sp=0x140000557d0 pc=0x100dfb534 created by runtime.gcenable in goroutine 1 /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgc.go:203 +0x6c goroutine 4 gp=0x140000036c0 m=nil [GC scavenge wait]: runtime.gopark(0x14000088000?, 0x100ec54f0?, 0x1?, 0x0?, 0x140000036c0?) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:402 +0xc8 fp=0x14000055f60 sp=0x14000055f40 pc=0x100dc5088 runtime.goparkunlock(...) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:408 runtime.(*scavengerState).park(0x100fd9220) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgcscavenge.go:425 +0x5c fp=0x14000055f90 sp=0x14000055f60 pc=0x100dad42c runtime.bgscavenge(0x14000088000) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgcscavenge.go:653 +0x44 fp=0x14000055fb0 sp=0x14000055f90 pc=0x100dad984 runtime.gcenable.gowrap2() /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgc.go:204 +0x28 fp=0x14000055fd0 sp=0x14000055fb0 pc=0x100da3bf8 runtime.goexit({}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x14000055fd0 sp=0x14000055fd0 pc=0x100dfb534 created by runtime.gcenable in goroutine 1 /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mgc.go:204 +0xac goroutine 5 gp=0x14000003c00 m=nil [finalizer wait]: runtime.gopark(0x0?, 0x0?, 0xb8?, 0x45?, 0x100df6aa4?) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/proc.go:402 +0xc8 fp=0x14000054580 sp=0x14000054560 pc=0x100dc5088 runtime.runfinq() /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mfinal.go:194 +0x108 fp=0x140000547d0 sp=0x14000054580 pc=0x100da2d28 runtime.goexit({}) /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/asm_arm64.s:1222 +0x4 fp=0x140000547d0 sp=0x140000547d0 pc=0x100dfb534 created by runtime.createfing in goroutine 1 /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/mfinal.go:164 +0x80 FAIL github.com/ahfuzhang/spscqueue 0.657s
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】