-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: error returned by os.OpenFile blocks panic handler #14432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
/cc @alexbrainman |
Interesting. The program could be further simplified to:
package main
import "syscall"
func main() {
panic(syscall.Errno(0x50))
}
|
The FormatMessageW syscall returns successfully,
but after that the runtime deadlocks in stoplockedm
(line 1682 of runtime/proc.go, `notesleep(&_g_.m.park)`)
|
OK, it's because startpanic_m has already called
freezetheworld() (and set sched.gcwaiting to 1).
Calling any cgocall after that point is going to deadlock.
Normally this won't be a problem, but Windows
syscall.Errno.Error() relies on cgocalls to retrieve
the error messages.
I don't know how to fix this problem. Any suggestions?
/cc @aclements
|
Interesting. I wonder if we shouldn't be calling in to user code to format the panic message after freezing the world. Presumably on any platform, if an Error method calls cgo or does something nontrivial with goroutines or something, it would deadlock the system in the same way. We could format all of the panic messages first, then freeze the world, then print them. |
This also means we're calling in to user code while holding a runtime lock (paniclk). For example, the following results in a "panic: fatal error: schedule: holding locks", which should not be triggerable by user code:
|
This one deadlocks on Linux (I haven't looked in to why the Println is necessary):
And this one panics with another internal error, "fatal error: stopm holding locks":
These both work in 1.4.3, but not 1.5. |
CL https://golang.org/cl/19792 mentions this issue. |
go1.6 windows/amd64 on Windows 8
The following program tries to create a new file with os.O_EXCL and panics if the file already exists. When
panic(err)
is called, "panic:" is written to stderr and the program blocks. You have to terminate it with Ctrl-C. If you uncomment err.Error() then you get a normal backtrace and the program exits.I'm guessing that there is a problem with retrieving the error information in the panic handler, but if done before panicking, then everything works as expected.
The text was updated successfully, but these errors were encountered: