-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cgo: crash when calling strtod on windows/amd64 #8941
Labels
Milestone
Comments
It crashes on my computer with Windows 7 too. C:\Users\rin01>go version go version go1.3.3 windows/amd64 C:\Users\rin01>gcc --version gcc (tdm64-2) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The same problem also exists when strtoll("9223372036854775808", NULL, 10) is used in cgo, which crashes the following program: http://play.golang.org/p/W4wSfzw1X- |
strtod() crashes inside atexit(), because go linker bypasses CRT initialization (mainCRTStartup/WinMainCRTStatrup), leaving some globals with incorrect state. The solution is to use external linking mode, except it's not supported on Windows. strtoll() crash is a different problem. MinGW CRT calls errno() (exported from msvcrt.dll) through a stub function _errno, which indirectly calls __imp__errno (actual imported function pointer). To overcome 6l limitations, cgo rewrites imports, which results in __imp__errno being called _errno and the stub _errno called from CRT being discarded. Now strtoll that called this stub crashes, because _errno symbol has changed its meaning. Regardless, the solution is the same: use a fully functional linker. |
I'm still surprised to see calling strtod requires atexit.
Yes, this should be fixed by external linking (#4069).
@alex.brainman, yes, adding a test would be good, but
note that every test in misc/cgo/test needs to pass
with both internal and external linking.
|
I didn't know that. So were should I add this test? runtime? Alex |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: