-
Kirill Smelkov authored
Fix StopTheWorld crash due to change in runtime.stopTheWorld signature: In Go1.21 stopTheWorld changed from accepting reason as string into accepting reason as uint8 code: https://github.com/golang/go/commit/b1aadd034c1f https://golang.org/cl/494495 which leads to the following crash if reason is still passed as string: fatal error: index out of range goroutine 6 [running]: runtime.throw({0x531aad?, 0x0?}) /home/kirr/src/tools/go/go/src/runtime/panic.go:1077 +0x5c fp=0xc000042608 sp=0xc0000425d8 pc=0x4365bc runtime.panicCheck1(0x4785af?, {0x531aad, 0x12}) /home/kirr/src/tools/go/go/src/runtime/panic.go:58 +0x94 fp=0xc000042628 sp=0xc000042608 pc=0x434034 runtime.goPanicIndex(0x8d, 0x11) /home/kirr/src/tools/go/go/src/runtime/panic.go:113 +0x2e fp=0xc000042668 sp=0xc000042628 pc=0x4340ee runtime.stwReason.String(...) /home/kirr/src/tools/go/go/src/runtime/proc.go:1217 runtime.stopTheWorld(0x8d) /home/kirr/src/tools/go/go/src/runtime/proc.go:1260 +0xe6 fp=0xc0000426c8 sp=0xc000042668 pc=0x43b3a6 lab.nexedi.com/kirr/go123/tracing/internal/xruntime.StopTheWorld(...) /home/kirr/src/neo/src/lab.nexedi.com/kirr/go123/tracing/internal/xruntime/runtime.go:40 lab.nexedi.com/kirr/go123/tracing/internal/xruntime.TestStartStopTheWorld(0xc000007860) /home/kirr/src/neo/src/lab.nexedi.com/kirr/go123/tracing/internal/xruntime/runtime_test.go:75 +0x139 fp=0xc000042770 sp=0xc0000426c8 pc=0x4fa0f9 testing.tRunner(0xc000007860, 0x53a8b8) /home/kirr/src/tools/go/go/src/testing/testing.go:1595 +0xff fp=0xc0000427c0 sp=0xc000042770 pc=0x4bbd9f testing.(*T).Run.func1() /home/kirr/src/tools/go/go/src/testing/testing.go:1648 +0x25 fp=0xc0000427e0 sp=0xc0000427c0 pc=0x4bcd25 runtime.goexit() /home/kirr/src/tools/go/go/src/runtime/asm_amd64.s:1650 +0x1 fp=0xc0000427e8 sp=0xc0000427e0 pc=0x468901 created by testing.(*T).Run in goroutine 1 /home/kirr/src/tools/go/go/src/testing/testing.go:1648 +0x3ad -> Fix it by accounting that STW reason is uint8 on go1.21 and passing it to runtime correspondingly. Sadly we cannot express arbitrary string reason into fixed list of reasons that runtime and stdlib tracing are aware of, so we always use "unknown" for custom stop-the-world requests.
95433de3