diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go index 2c990c199c..38ff602096 100644 --- a/src/runtime/crash_test.go +++ b/src/runtime/crash_test.go @@ -792,11 +792,6 @@ func TestRuntimePanic(t *testing.T) { func TestG0StackOverflow(t *testing.T) { testenv.MustHaveExec(t) - switch runtime.GOOS { - case "android", "darwin", "dragonfly", "freebsd", "ios", "linux", "netbsd", "openbsd": - t.Skipf("g0 stack is wrong on pthread platforms (see golang.org/issue/26061)") - } - if os.Getenv("TEST_G0_STACK_OVERFLOW") != "1" { cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=^TestG0StackOverflow$", "-test.v")) cmd.Env = append(cmd.Env, "TEST_G0_STACK_OVERFLOW=1") diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index c43c5d0551..008d2042cd 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -682,6 +682,15 @@ func unexportedPanicForTesting(b []byte, i int) byte { func G0StackOverflow() { systemstack(func() { + g0 := getg() + sp := getcallersp() + // The stack bounds for g0 stack is not always precise. + // Use an artificially small stack, to trigger a stack overflow + // without actually run out of the system stack (which may seg fault). + g0.stack.lo = sp - 4096 + g0.stackguard0 = g0.stack.lo + stackGuard + g0.stackguard1 = g0.stackguard0 + stackOverflow(nil) }) }