-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
runtime: badsignal2 crash on windows/arm64 #56080
Comments
cc @golang/windows @golang/runtime |
@billziss-gh thanks for report. I am not familiar enough with arm64 assembler, but I am pretty sure you are correct. Please feel free to send fix for this issue. Here https://go.dev/doc/contribute is how to contribute. Or you can just create Github PR, and Go bot will automatically create Gerrit CL for you. Thank you. Alex |
CC @qmuntal in case you are interested Alex |
The following one-line patch appears to fix the problem on my Windows/ARM machine (i.e. diff --git a/src/runtime/sys_windows_arm64.s b/src/runtime/sys_windows_arm64.s
index 024625f821..0a293ec317 100644
--- a/src/runtime/sys_windows_arm64.s
+++ b/src/runtime/sys_windows_arm64.s
@@ -113,7 +113,7 @@ TEXT runtime·badsignal2(SB),NOSPLIT,$16-0
MOVD $runtime·badsignalmsg(SB), R1 // lpBuffer
MOVD $runtime·badsignallen(SB), R2 // lpNumberOfBytesToWrite
MOVD (R2), R2
- MOVD R13, R3 // lpNumberOfBytesWritten
+ ADD $0x10, RSP, R3 // lpNumberOfBytesWritten
MOVD $0, R4 // lpOverlapped
MOVD runtime·_WriteFile(SB), R12
SUB $16, RSP // skip over saved frame pointer below RSP Please note that I am not familiar with Go's assembly and consequently this patch may be brittle. For example, if there is a change in the frame prolog that the Go assembler outputs, the offset to add to |
I confirm that with @billziss-gh patch On the other hand, I don't think that the expected message should be Summary:
|
@qmuntal as per your request I have submitted a PR with the above patch. |
Change https://go.dev/cl/442216 mentions this issue: |
Initializes the R3 register with an available address in the stack. The addressed location is used to receive the number of bytes written by WriteFile. Fixes golang#56080 Change-Id: I0368eb7a31d2d6a098fa9c26e074eb1114a92704 GitHub-Last-Rev: 23dbdb5 GitHub-Pull-Request: golang#56153 Reviewed-on: https://go-review.googlesource.com/c/go/+/442216 Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Cherry Mui <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, with the latest major version (1.19).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran a Golang program that uses a DLL that raises a Windows exception in a non-Golang thread. This results in a call to
runtime.badsignal2
viaruntime.sigtramp
.What did you expect to see?
I expected to see the message
runtime: signal received on thread not created by Go
.What did you see instead?
An Access Violation in
WriteFile
.Problem and solution
The problem is that
WriteFile
expects a valid pointer for thelpNumberOfBytesWritten
parameter. Howeverbadsignal2
seems to initialize thex3
register (which contains thelpNumberOfBytesWritten
argument) to a bogus value.The solution is to properly initialize
x3
prior to callingWriteFile
.See also
#50877
rclone/rclone#5828 (comment)
The text was updated successfully, but these errors were encountered: