-
Notifications
You must be signed in to change notification settings - Fork 890
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
form: don't use Go heap for MSG #493
Conversation
It's not entirely clear to me what's going on here, and I'm only half-certain that this fixes the issue, due to it being somewhat hard to reproduce. However, here's what I suspect is going on. Because we're passing this as a pointer to various levels of function calls that might store a reference to the pointer, Go allocates the variable on the heap. Later, various closures are allocated on the same heap, during which time some global Go lock is taken and W^X page permissions are twiddled with. The Go locking then doesn't effect functions that are in win32api calls, and at the critical moment, the variable no longer has writable page permissions. While this might point to deeper Go runtime issues, we just work around this here by allocating the variable using GlobalAlloc. At the very least, I haven't been able to reproduce the bug after applying this patch. Fixes: lxn#483 Signed-off-by: Jason A. Donenfeld <[email protected]>
I'm not 100% that this actually works or that the analysis is correct, so please test it for a bit and see if you can reproduce the crashes. |
@StephanVerbeeck - can you verify that this fixes the issue for you? |
With pleasure, but it will take a few days as the errors occurrence is infrequent and with irregular timing. |
hmmmmmmm . . . . issue #491 seems to be fixed by this :-) :-O |
Thanks for getting to the bottom of this!
Why does the go runtime tweak page permissions? |
The crash did not occur since (there were some other but not related to the dialog message) |
Exception 0xc0000005 0x0 0x1749111c 0x77e47594 syscall.Syscall6(0x7598a5b0, 0x4, 0x27066f8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...) |
It seems to have something to do with the operating system |
This fixes random AccessViolations during Dispatch/GetMessage. See lxn/walk#493 Fix wailsapp/wails#1083
It's not entirely clear to me what's going on here, and I'm only
half-certain that this fixes the issue, due to it being somewhat hard to
reproduce. However, here's what I suspect is going on. Because we're
passing this as a pointer to various levels of function calls that might
store a reference to the pointer, Go allocates the variable on the heap.
Later, various closures are allocated on the same heap, during which
time some global Go lock is taken and W^X page permissions are twiddled
with. The Go locking then doesn't effect functions that are in win32api
calls, and at the critical moment, the variable no longer has writable
page permissions. While this might point to deeper Go runtime issues, we
just work around this here by allocating the variable using GlobalAlloc.
At the very least, I haven't been able to reproduce the bug after
applying this patch.
Fixes: #483