runtime: ensure stack is aligned in _rt0_amd64_windows_lib #662
+6
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Windows DLL loader may call a DLL entry point, in our case _rt0_amd64_windows_lib, with a stack that is
not 16-byte aligned. In theory, it shouldn't, but under some circumstances, it does (see below how to reproduce it).
Having an unaligned stack can, and probably will, cause problems down the line, for example if a movaps instruction tries to store a value in an unaligned address it throws an Access Violation exception (code 0xc0000005).
I managed to consistently reproduce this issue by loading a Go DLL into a C program that has the Page Heap Verification diagnostic enabled [1].
Updates golang#54187 (and potentially fixes)
[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/example-12---using-page-heap-verification-to-find-a-bug
Change-Id: Id0fea7f407e024c9b8cdce10ce4802d7535e7542
Reviewed-on: https://go-review.googlesource.com/c/go/+/510755
TryBot-Result: Gopher Robot [email protected]
Reviewed-by: Cherry Mui [email protected]
Reviewed-by: Than McIntosh [email protected]
Run-TryBot: Quim Muntal [email protected]
This PR will be imported into Gerrit with the title and first
comment (this text) used to generate the subject and body of
the Gerrit change.
Please ensure you adhere to every item in this list.
More info can be found at https://github.com/golang/go/wiki/CommitMessage
net/http: frob the quux before blarfing
"This change modifies Go to ___________"
really needed (ASCII art, table, or long link)
Fixes #1234
orUpdates #1234
(the latter if this is not a complete fix) to this comment
golang/go
you can use theowner/repo#issue_number
syntax:Fixes golang/tools#1234
Our Gerrit server & GitHub bots enforce CLA compliance instead.