Skip to content

Commit b51f1cd

Browse files
committed
runtime: remove arbitrary 5-second timeout in TestNeedmDeadlock
The NeedmDeadlock test program currently has a 5-second timeout, which is sort of arbitrary. It is long enough in regular mode (which usually takes 0.0X seconds), but not quite so for configurations like ASAN. Instead of using an arbitrary timeout, just use the test's deadline. The test program is invoked with testenv.Command, which will send it a SIGQUIT before the deadline expires. Fixes #56420 (at least for the asan builder). Change-Id: I0b13651cb07241401837ca2e60eaa1b83275b093 Reviewed-on: https://go-review.googlesource.com/c/go/+/684697 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 parent f1e6ae2 commit b51f1cd

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

‎src/runtime/testdata/testprogcgo/needmdeadlock.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ import "C"
7070

7171
import (
7272
"fmt"
73-
"os"
74-
"time"
7573
)
7674

7775
func init() {
@@ -84,12 +82,8 @@ func GoNeedM() {
8482

8583
func NeedmDeadlock() {
8684
// The failure symptom is that the program hangs because of a
87-
// deadlock in needm, so set an alarm.
88-
go func() {
89-
time.Sleep(5 * time.Second)
90-
fmt.Println("Hung for 5 seconds")
91-
os.Exit(1)
92-
}()
85+
// deadlock in needm. Instead of using an arbitrary timeout,
86+
// we let the test deadline expire if it deadlocks.
9387

9488
C.runNeedmSignalThread()
9589
fmt.Println("OK")

0 commit comments

Comments
 (0)