mirror of
https://github.com/golang/go
synced 2024-11-23 10:20:03 -07:00
b0a29f393b
* Separate internal and external LockOSThread, for cgo safety. * Show goroutine that made faulting cgo call. * Never start a panic due to a signal caused by a cgo call. Fixes #3774. Fixes #3775. Fixes #3797. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7228081
30 lines
462 B
Go
30 lines
462 B
Go
package cgotest
|
|
|
|
/*
|
|
void lockOSThreadCallback(void);
|
|
inline static void lockOSThreadC(void)
|
|
{
|
|
lockOSThreadCallback();
|
|
}
|
|
int usleep(unsigned usec);
|
|
*/
|
|
import "C"
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
func test3775(t *testing.T) {
|
|
// Used to panic because of the UnlockOSThread below.
|
|
C.lockOSThreadC()
|
|
}
|
|
|
|
//export lockOSThreadCallback
|
|
func lockOSThreadCallback() {
|
|
runtime.LockOSThread()
|
|
runtime.UnlockOSThread()
|
|
go C.usleep(10000)
|
|
runtime.Gosched()
|
|
}
|