1
0
mirror of https://github.com/golang/go synced 2024-10-04 20:11:22 -06:00
go/src/pkg/runtime/futex_test.go
Dmitriy Vyukov e84d9e1fb3 runtime: do not split stacks in syscall status
Split stack checks (morestack) corrupt g->sched,
but g->sched must be preserved consistent for GC/traceback.
The change implements runtime.notetsleepg function,
which does entersyscall/exitsyscall and is carefully arranged
to not call any split functions in between.

R=rsc
CC=golang-dev
https://golang.org/cl/11575044
2013-07-29 22:22:34 +04:00

35 lines
758 B
Go

// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Futex is only available on Linux and FreeBSD.
// The race detector emits calls to split stack functions so it breaks the test.
// +build linux freebsd
// +build !race
package runtime_test
import (
. "runtime"
"testing"
"time"
)
func TestFutexsleep(t *testing.T) {
ch := make(chan bool, 1)
var dummy uint32
start := time.Now()
go func() {
Entersyscall()
Futexsleep(&dummy, 0, (1<<31+100)*1e9)
Exitsyscall()
ch <- true
}()
select {
case <-ch:
t.Errorf("futexsleep finished early after %s!", time.Since(start))
case <-time.After(time.Second):
Futexwakeup(&dummy, 1)
}
}