aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/crash_unix_test.go
AgeCommit message (Collapse)Author
2021-05-09runtime: skip TestCrashDumpsAllThreads on openbsd/armJoel Sing
This test is also now flakey on this platform. Updates #36435 Updates #42464 Change-Id: Idedb81478178ffffe7a9c125a6e8bbd83458f9ab Reviewed-on: https://go-review.googlesource.com/c/go/+/315794 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-04-22runtime: don't run TestCrashDumpsAllThreads in parallelIan Lance Taylor
It sometimes seems to time out on slow systems, perhaps due to being run at the same time as a lot of other work. Also move the code to testdata/testprog, so that we don't have to build it separately. I hope that this Fixes #35356 Change-Id: I875b858fa23836513ae14d3116461e22fffd5352 Reviewed-on: https://go-review.googlesource.com/c/go/+/312510 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-08runtime: replace os.MkdirTemp with T.TempDirianwoolf
Updates #45402 Change-Id: I3aa82fc2486b4de49b45388bbab24f5ffe558f91 Reviewed-on: https://go-review.googlesource.com/c/go/+/307989 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-11-30runtime: gofmtKimMachineGun
CL 268578 was not formatted properly. Change-Id: I08d2fc691e4f90a38d8165344c135b7b4f73b339 GitHub-Last-Rev: 6183bb063962ef4bf5a6050c1f5108976108ff42 GitHub-Pull-Request: golang/go#42736 Reviewed-on: https://go-review.googlesource.com/c/go/+/271807 Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Pratt <mpratt@google.com> Trust: Alberto Donizetti <alb.donizetti@gmail.com> Run-TryBot: Michael Pratt <mpratt@google.com>
2020-11-18runtime: give test child time to blockMichael Pratt
The child in TestPanicSystemstack prints "x\n" and then blocks on a lock. Receiving those bytes only indicates that the child is _about to block_. Since we don't have a way to know when it is fully blocked, sleep a bit to give it time to block. This makes us less likely to lose the race and signal before the child blocks, which will fail the test as the stack trace cannot be read from a running G. Fixes #33626 Change-Id: I8a27b1b114bf75e1e5bcb2a7a33aa69cdbc22f40 Reviewed-on: https://go-review.googlesource.com/c/go/+/268578 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2020-11-09runtime: disable TestCrashDumpsAllThreads on openbsd/mips64Joel Sing
This test fails consistently on openbsd/mips64 - disable it until we can investigate and resolve the issue. Updates #42464 Change-Id: Ie640f776823137a967a12817ff18953207f558a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/268438 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-10-28runtime: move TestNeedmDeadlock to crash_cgo_test.goIan Lance Taylor
It requires cgo. Also, skip the test on windows and plan9. For #42207 Change-Id: I8522773f93bc3f9826506a41a08b86a083262e31 Reviewed-on: https://go-review.googlesource.com/c/go/+/265778 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-28runtime: block signals in needm before allocating MIan Lance Taylor
Otherwise, if a signal occurs just after we allocated the M, we can deadlock if the signal handler needs to allocate an M itself. Fixes #42207 Change-Id: I76f44547f419e8b1c14cbf49bf602c6e645d8c14 Reviewed-on: https://go-review.googlesource.com/c/go/+/265759 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-03-11runtime: skip TestSignalIgnoreSIGTRAP on known-flaky OpenBSD buildersBryan C. Mills
This test is flaky, and the cause is suspected to be an OpenBSD kernel bug. Since there is no obvious workaround on the Go side, skip the test on builders whose versions are known to be affected. Fixes #17496 Change-Id: Ifa70061eb429e1d949f0fa8a9e25d177afc5c488 Reviewed-on: https://go-review.googlesource.com/c/go/+/222856 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
2019-11-18runtime: remove stray errno check from TestSignalMTom Thorogood
CL 206078 introduced a stray errno check that was always false. This CL removes it. Updates #35276 Change-Id: I6996bb595d347fe81752786a3d83d3432735c9cb GitHub-Last-Rev: e026e71b16c8532ad707a0b43b4f02c7a366257e GitHub-Pull-Request: golang/go#35650 Reviewed-on: https://go-review.googlesource.com/c/go/+/207577 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-11-12runtime: use pipe rather than note in TestSignalMIan Lance Taylor
At least on Darwin notewakeup is not async-signal-safe. Fixes #35276 Change-Id: I1d7523715e8e77dbd7f21d9b1ed131e52d46cc41 Reviewed-on: https://go-review.googlesource.com/c/go/+/206078 Reviewed-by: Austin Clements <austin@google.com>
2019-11-07runtime: set GODEBUG=asyncpreemptoff=1 in TestCrashDumpsAllThreadsIan Lance Taylor
Fixes #35356 Change-Id: I67b9e57b88d00ed98cbc3aa0aeb26b5f2d75a3f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/205720 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-11-06runtime: remove stale runtime check in testsDmitry Vyukov
The check is not relevant anymore. The comment claims that go run does not rebuild packages, but this is not true. And we use go build anyway. We may have added the check because without caching rebuilding everything starting from runtime for each test takes a while. But now we have caching. So from every side this check just adds code and pain. Change-Id: Ifbbb643724100622e5f9db884339b67cde4ba729 Reviewed-on: https://go-review.googlesource.com/c/go/+/202450 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-29runtime: rename TestPreemptM to TestSignalMAustin Clements
TestPreemptM doesn't test preemptM, it tests signalM. Rename it and co-locate it with the other tests related to signals. Change-Id: I7b95f2ba96530c49cfa8d5bf33282946b5f2d9af Reviewed-on: https://go-review.googlesource.com/c/go/+/203891 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-21runtime: change read and write to return negative errno valueIan Lance Taylor
The internal read and write functions used to return -1 on error; change them to return a negative errno value instead. This will be used by later CLs in this series. For most targets this is a simplification, although for ones that call into libc it is a complication. Updates #27707 Change-Id: Id02bf9487f03e7e88e4f2b85e899e986738697ad Reviewed-on: https://go-review.googlesource.com/c/go/+/171823 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-05-16runtime: disable some tests in -quick modeRuss Cox
Speeds up the "go test runtime -cpu=1,2,4 -short -quick" phase of all.bash. For #26473. Change-Id: I090f5a5aa754462b3253a2156dc31fa67ce7af2a Reviewed-on: https://go-review.googlesource.com/c/go/+/177399 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2019-04-30all: add new GOOS=illumos, split out of GOOS=solarisJoshua M. Clulow
Like GOOS=android which implies the "linux" build tag, GOOS=illumos implies the "solaris" build tag. This lets the existing ecosystem of packages still work on illumos, but still permits packages to start differentiating between solaris and illumos. Fixes #20603 Change-Id: I8f4eabf1a66060538dca15d7658c1fbc6c826622 Reviewed-on: https://go-review.googlesource.com/c/go/+/174457 Run-TryBot: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-02-19runtime: make tests that invoke 'go build' module-agnosticBryan C. Mills
In module mode, building the current directory requires a go.mod file (in order to determine the import path of the package). Change the tests to pass explicit file arguments instead, since those can be built in module mode without defining a module. Updates #30228 Change-Id: I680c658d1f79645f73ad4d1e88189ea50a4852e9 Reviewed-on: https://go-review.googlesource.com/c/162837 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2018-10-03runtime: add AIX operating systemClément Chigot
This commit adds AIX operating system to runtime package for ppc64 architecture. Only new files and minor changes are in this commit. Others modifications in files like asm_ppc64.s will be in separate commits. Updates: #25893 Change-Id: I9c5e073f5f3debb43b004ad1167694a5afd31cfd Reviewed-on: https://go-review.googlesource.com/c/138716 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-13cmd/compile: add TestIntendedInlining from runtimeDaniel Martí
Move it from the runtime package, as we will soon add more packages and functions for it to check. The test used the testEnv func, which cleaned certain environment variables from a command, so it was moved to internal/testenv under a more descriptive (and less ambiguous) name. Add a simple godoc to it too. For #21851. Change-Id: I6f39c1f23b45377718355fafe66ffd87047d8ab6 Reviewed-on: https://go-review.googlesource.com/63550 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
2017-07-20runtime: use SIGKILL if SIGQUIT is blocked; skip tests that need SIGQUITAustin Clements
The runtime tests may be invoked from a parent that has SIGQUIT blocked. For example, Java invokes subprocesses this way. In this situation, TestCrashDumpsAllThreads and TestPanicSystemstack will fail because they depend on SIGQUIT to get tracebacks, and any subprocess test that times out will fail to kill the subprocess. Fix this by detecting if SIGQUIT is blocked and, if so, skipping tests that depend on it and using SIGKILL to kill timed-out subprocesses. Based on a fix by Carl Henrik Lunde in https://golang.org/issue/19196#issuecomment-316145733 Fixes #19196. Change-Id: Ia20bf15b96086487d0ef6b75239dcc260c21714c Reviewed-on: https://go-review.googlesource.com/50330 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-14runtime, syscall: reset signal handlers to default in childIan Lance Taylor
Block all signals during a fork. In the parent process, after the fork, restore the signal mask. In the child process, reset all currently handled signals to the default handler, and then restore the signal mask. The effect of this is that the child will be operating using the same signal regime as the program it is about to exec, as exec resets all non-ignored signals to the default, and preserves the signal mask. We do this so that in the case of a signal sent to the process group, the child process will not try to run a signal handler while in the precarious state after a fork. Fixes #18600. Change-Id: I9f39aaa3884035908d687ee323c975f349d5faaa Reviewed-on: https://go-review.googlesource.com/45471 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2017-03-15runtime: print user stack on other threads during GOTRACBEACK=crashAustin Clements
Currently, when printing tracebacks of other threads during GOTRACEBACK=crash, if the thread is on the system stack we print only the header for the user goroutine and fail to print its stack. This happens because we passed the g0 to traceback instead of curg. The g0 never has anything set in its gobuf, so traceback doesn't print anything. Fix this by passing _g_.m.curg to traceback instead of the g0. Fixes #19494. Change-Id: Idfabf94d6a725e9cdf94a3923dead6455ef3b217 Reviewed-on: https://go-review.googlesource.com/38012 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-04all: sprinkle t.Parallel on some slow testsBrad Fitzpatrick
I used the slowtests.go tool as described in https://golang.org/cl/32684 on packages that stood out. go test -short std drops from ~56 to ~52 seconds. This isn't a huge win, but it was mostly an exercise. Updates #17751 Change-Id: I9f3402e36a038d71e662d06ce2c1d52f6c4b674d Reviewed-on: https://go-review.googlesource.com/32751 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-30all: use testing.GoToolPath instead of "go"Keith Randall
This change makes sure that tests are run with the correct version of the go tool. The correct version is the one that we invoked with "go test", not the one that is first in our path. Fixes #16577 Change-Id: If22c8f8c3ec9e7c35d094362873819f2fbb8559b Reviewed-on: https://go-review.googlesource.com/28089 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-15runtime: if the test program hangs, try to get a stack traceIan Lance Taylor
This is an attempt to get more information for #14809, which seems to occur rarely. Updates #14809. Change-Id: Idbeb136ceb57993644e03266622eb699d2685d02 Reviewed-on: https://go-review.googlesource.com/24110 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Reviewed-by: Austin Clements <austin@google.com>
2016-05-18runtime: deflake TestSignalExitStatusIan Lance Taylor
The signal might get delivered to a different thread, and that thread might not run again before the currently running thread returns and exits. Sleep to give the other thread time to pick up the signal and crash. Not tested for all cases, but, optimistically: Fixes #14063. Change-Id: Iff58669ac6185ad91cce85e0e86f17497a3659fd Reviewed-on: https://go-review.googlesource.com/23203 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-02-16runtime: fix deadlock in TestCrashDumpsAllThreadsAustin Clements
TestCrashDumpsAllThreads carefully sets the number of Ps to one greater than the number of non-preemptible loops it starts so that the main goroutine can continue to run (necessary because of #10958). However, if GC starts, it can take over that one spare P and lock up the system while waiting for the non-preemptible loops, causing the test to eventually time out. This deadlock is easily reproducible if you run the runtime test with GOGC=1. Fix this by forcing GOGC=off when running this test. Change-Id: Ifb22da5ce33f9a61700a326ea92fcf4b049721d1 Reviewed-on: https://go-review.googlesource.com/19516 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-04runtime: skip TestSignalExitStatus on SolarisIan Lance Taylor
Update #14063. Change-Id: Id13456deb15c90a8af282b77d78ff5cdbd1de8bf Reviewed-on: https://go-review.googlesource.com/19208 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Minux Ma <minux@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-22runtime: skip TestSignalExitStatus on NetBSDIan Lance Taylor
It doesn't work and I don't know why. Update #14063. Change-Id: I42735012cf6247eca5336f29fcf713e08c8477f8 Reviewed-on: https://go-review.googlesource.com/18817 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-08runtime: allow signal.Ignore of user-generated throwing signalsRuss Cox
Today, signal.Ignore(syscall.SIGTRAP) does nothing while signal.Notify(make(chan os.Signal), syscall.SIGTRAP) correctly discards user-generated SIGTRAPs. The same applies to any signal that we throw on. Make signal.Ignore work for these signals. Fixes #12906. Change-Id: Iba244813051e0ce23fa32fbad3e3fa596a941094 Reviewed-on: https://go-review.googlesource.com/18348 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-05runtime: fix exit status when killed by signalIan Lance Taylor
Previously, when a program died because of a SIGHUP, SIGINT, or SIGTERM signal it would exit with status 2. This CL fixes the runtime to exit with a status indicating that the program was killed by a signal. Change-Id: Ic2982a2562857edfdccaf68856e0e4df532af136 Reviewed-on: https://go-review.googlesource.com/18156 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2015-07-27runtime: log all thread stack traces during GODEBUG=crash on UnixIan Lance Taylor
This extends https://golang.org/cl/2811, which only applied to Darwin and GNU/Linux, to all Unix systems. Fixes #9591. Change-Id: Iec3fb438564ba2924b15b447c0480f87c0bfd009 Reviewed-on: https://go-review.googlesource.com/12661 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Russ Cox <rsc@golang.org>