diff options
| author | Russ Cox <rsc@golang.org> | 2012-03-08 12:12:40 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-03-08 12:12:40 -0500 |
| commit | 9b73238daa6a5d08eb2265fc38577cb6003f0d23 (patch) | |
| tree | 00d9bf92376ea354da9b197fb6c3a60f1517e5da /src/pkg/runtime/thread_linux.c | |
| parent | 9b7b574edcff14d916215a72b7a9fc8bb82ab16e (diff) | |
| download | go-9b73238daa6a5d08eb2265fc38577cb6003f0d23.tar.xz | |
cgo, runtime: diagnose callback on non-Go thread
Before:
$ go run x.go
signal 11 (core dumped)
$
After:
$ go run x.go
runtime: cgo callback on thread not created by Go.
signal 11 (core dumped)
$
For issue 3068.
Not a fix, but as much of a fix as we can do before Go 1.
R=golang-dev, rogpeppe, gri
CC=golang-dev
https://golang.org/cl/5781047
Diffstat (limited to 'src/pkg/runtime/thread_linux.c')
| -rw-r--r-- | src/pkg/runtime/thread_linux.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pkg/runtime/thread_linux.c b/src/pkg/runtime/thread_linux.c index 6b428440e0..af765d53b9 100644 --- a/src/pkg/runtime/thread_linux.c +++ b/src/pkg/runtime/thread_linux.c @@ -255,3 +255,13 @@ runtime·setprof(bool on) { USED(on); } + +static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n"; + +// This runs on a foreign stack, without an m or a g. No stack split. +#pragma textflag 7 +void +runtime·badcallback(void) +{ + runtime·write(2, badcallback, sizeof badcallback - 1); +} |
