Commit 76f71959 authored by Austin Clements's avatar Austin Clements

runtime: restore error message on early needm

needm used to print an error before exiting when it was called too
early, but this error was lost in the transition to Go.  Bring back
the error so we don't silently exit(1) when this happens.

Change-Id: I8086932783fd29a337d7dea31b9d6facb64cb5c1
Reviewed-on: https://go-review.googlesource.com/1226Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent e8f13700
......@@ -861,8 +861,7 @@ func needm(x byte) {
if needextram != 0 {
// Can happen if C/C++ code calls Go from a global ctor.
// Can not throw, because scheduler is not initialized yet.
// XXX
// write(2, unsafe.Pointer("fatal error: cgo callback before cgo call\n"), sizeof("fatal error: cgo callback before cgo call\n") - 1)
write(2, unsafe.Pointer(&earlycgocallback[0]), int32(len(earlycgocallback)))
exit(1)
}
......@@ -898,6 +897,8 @@ func needm(x byte) {
minit()
}
var earlycgocallback = []byte("fatal error: cgo callback before cgo call\n")
// newextram allocates an m and puts it on the extra list.
// It is called with a working local m, so that it can do things
// like call schedlock and allocate.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment