-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: windows syscall with callback that grow stack returns wrong value #10406
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
Is this another case where the pointer is turned into a uintptr and handed to Windows, so that the escape analysis can't see that the pointer has escaped? The solution if so is not to do that. |
I suspect so, but it is updated by our assembler asmstdcall function, not Windows. What should I do here? Ho can I pass this information if not on stack? Alex |
@alexbrainman You can allocate LibCall in heap (or better make it a part of M struct) |
Maybe I will put it into M. We already do something like that for stdcall. What should I do for syscalls inside windows callback? Save / restore them at the callback start / end? Sounds complicated just for return value and error. Alex |
Save/restore what? I would try the following scheme. |
We could save m.libcall value into local stack variable at the start of callback, and restore it on the way out of callback. I will try think of something. Thank you @dvyukov . Alex |
CL https://golang.org/cl/10370 mentions this issue. |
Isn't this broken in Go 1.4.* too? I'm having some weird behaviors on Windows (and there's some initial suspicion they might be return-related), when trying to work with WinAPI (e.g. apparently in WinAPI -> callback -> WinAPI -> callback chains). Not sure if they're the same case, but I've just tried tip, and they seem to disappear magically (i.e. works ok). |
Sure this is broken in go1.4.*. Similar I had unexplained returned values from Windows GetMessage. There might be others. This also will cause memory corruption, since those correct return values are written somewhere else. Alex |
Apply this diff:
to cb10ff1 and run new test:
If you comment out call to forceStackCopy, then the test succeeds.
Alex
The text was updated successfully, but these errors were encountered: