go: runtime: TestGdbCoreCrashThreadBacktrace failures
#!watchflakes
post <- pkg == "runtime" && test == "TestGdbCoreCrashThreadBacktrace"
Issue created automatically to collect these failures.
Example (log):
--- FAIL: TestGdbCoreCrashThreadBacktrace (7.67s)
runtime-gdb_test.go:81: gdb version 10.1
runtime-gdb_unix_test.go:334: child output:
Setting RLIMIT_CORE = syscall.Rlimit{Cur:0xffffffffffffffff, Max:0xffffffffffffffff}
SIGSEGV: segmentation violation
PC=0x48cc65 m=0 sigcode=1 addr=0x0
signal arrived during cgo execution
goroutine 1 gp=0xc0000081c0 m=0 mp=0x548740 [syscall]:
runtime.cgocall(0x48cc6e, 0xc00006ff20)
...
#19 0x000000000043b076 in runtime.mstart0 () at /workdir/go/src/runtime/proc.go:1684
#20 0x0000000000462c65 in runtime.mstart () at /workdir/go/src/runtime/asm_amd64.s:394
#21 0x000000000048d669 in crosscall1 () at gcc_amd64.S:42
#22 0x0000000000802000 in ?? ()
#23 0x00007f8b74b75fc0 in ?? ()
#24 0x00007ffd0d4c302f in ?? ()
#25 0x000000c000008a80 in ?? ()
#26 0x0000000000462c60 in ?? ()
#27 0x0000000000000000 in ?? ()
runtime-gdb_unix_test.go:375: could not find trigger_crash in backtrace
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- runtime: crash asap and extend total sleep time for slow machine in test Fixes #64752 — committed to zzkcode/go by zzkcode 3 years ago
- runtime: crash asap and extend total sleep time for slow machine in test Fixes #64752 — committed to zzkcode/go by zzkcode 3 years ago
- runtime: crash asap and extend total sleep time for slow machine in test Fixes #64752 — committed to zzkcode/go by zzkcode 3 years ago
- runtime: mark TestGdbCoreCrashThreadBacktrace as flaky This test exercises the SIGQUIT crash loop and managed to trigger the race from #65138 at least once. For #65138. Fixes #64752. Change-Id: I11... — committed to mauri870/go by prattmic 3 years ago
- runtime: mark TestGdbCoreCrashThreadBacktrace as flaky This test exercises the SIGQUIT crash loop and managed to trigger the race from #65138 at least once. For #65138. Fixes #64752. Change-Id: I11... — committed to ezz-no/go-ezzno by prattmic 3 years ago
- runtime: crash asap and extend total sleep time for slow machine in test Fixes #64752 — committed to zzkcode/go by zzkcode 3 years ago
- runtime: crash asap and extend total sleep time for slow machine in test Running with few threads usually does not need 500ms to crash, so let it crash as soon as possible. While the test may caused ... — committed to golang/go by zzkcode 3 years ago
Thanks for the analysis @bcmills! I agree with you, this looks like a genuine race condition. It is also note new in https://go.dev/cl/536895, it appears to have ~always existed (https://go.dev/cl/245018 extended the race window, but it was present before that too).
Regarding a fix, I’ll need to think some more. I’m not thrilled about masking signals, but I don’t have a better idea at the moment.
I could imagine this causing some of those other crashes, but not all. e.g., #60316: I don’t see how this could manifest as a SIGCHLD death.
Since this bug isn’t new, fixing it need not block the release, but we should still do something about the test. Should we mark it flaky until this bug is fixed?
Yep, I agree that a
testenv.SkipFlakyin the new test would be fine to unblock the Go 1.22 release.Some analysis of the test log reported by
watchflakes.The program ends up running six goroutines in total. When run on my workstation, at the time of the crash the goroutines are parked in the following locations:
maininC.trigger_crashforcegchelperingoparkunlockbgsweepingoparkunlockbgscavengeingoparkunlockrunfinqingoparksysmoninnotetsleepsysmongoroutine is not included in the output fromtracebackothers— I guess because it doesn’t have an associated P or G?)In a successful run on my local workstation, I see
SIGQUIT: quitlogs for five background threads:notetsleepviasysmonnotesleepviatemplateThreadstopmviascheduleandfindRunnableIn the builder log, we see
SIGQUIT: quitlogs for only four background threads:notetsleepviasysmon(as expected)notesleepviatemplateThread(as expected)allocmviaschedule,resetspinning, andnewmstopmviascheduleandstartlockedmThe thread in
allocmlooks suspiciously like a race in the runtime. In particular:startmcallsmReserveID(incrementingmnext) before it callsnewmnewmthread was interrupted bySIGQUITduringallocm, which is before the new thread is actually started for the M (innewm1).So this looks like a genuine watchdog failure: the kernel defers delivery of the final
SIGQUITsignal because all of the threads that could receive it are already handling aSIGQUIT(with that signal presumably masked), and themainthread is spinning in thedocrashloop waiting for acknowledgement from a fifth thread that had an M ID reserved but was never actually started.Perhaps
startmneeds to block signals from at some point before callingmReserveIDuntilnewmhas returned?This is a good point. This is an effect of https://cs.opensource.google/go/go/+/master:src/runtime/signal_unix.go;l=781;drc=de5b418bea70aaf27de1f47e9b5813940d1e15a4. The crashing thread will almost certainly sleep for 500ms at least once while waiting for SIGQUIT to make its rounds. IMO, we should just reduce this is something small, like 1ms, as it shouldn’t take long for other threads to exit.
Actually, a better theory:
usleepdoesn’t loop on early return of thenanosleepsyscall (e.g., if another signal is delivered), so it could return in <5s. We should really fix that.