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: golang.org/cl/46038 causes illegal instruction on FreeBSD/ARM #22248
Comments
CC @aclements What does gdb show in a backtrace from the point where the |
|
Thanks. @aclements If I'm reading the current code correctly, it is now possible for If that is the case, then the problem seems to be that in sys_freebsd_GOARCH.s, the |
Yes, though it will only do this if osStack is true. In that case, we didn't create the stack, so we assume that whatever started the thread left something on the stack for us to return to that will destroy the thread and reap the stack. In non-cgo FreeBSD, Oh! On cgo-using FreeBSD/arm, |
Change https://golang.org/cl/70830 mentions this issue: |
|
OK, my next probably dumb question is that I don't understand the
The comment on the |
Ah, indeed. Yet another reason why this isn't actually the problem. :)
You're right that this code is clearly wrong. In fact, it looks like it's wrong for several GOOSes. But I don't think this could be causing the SIGILL... |
@ianlancetaylor I think you've found it! if I move diff --git a/src/runtime/sys_freebsd_arm.s b/src/runtime/sys_freebsd_arm.s
index 0121e62309..a1b97db980 100644
--- a/src/runtime/sys_freebsd_arm.s
+++ b/src/runtime/sys_freebsd_arm.s
@@ -86,8 +86,8 @@ TEXT runtime·exit(SB),NOSPLIT,$-8
TEXT runtime<C2><B7>exitThread(SB),NOSPLIT,$0-4
MOVW wait+0(FP), R0
// We're done using the stack.
- MOVW $0, R1
storeloop:
+ MOVW $0, R1
LDREX (R0), R4 // loads R4
STREX R1, (R0), R1 // stores R2
CMP $0, R1 I'm able to single-step and hit the illegal instruction on
Which seems very weird, however if I just use diff --git a/src/runtime/sys_freebsd_arm.s b/src/runtime/sys_freebsd_arm.s
index 0121e62309..f277215ddc 100644
--- a/src/runtime/sys_freebsd_arm.s
+++ b/src/runtime/sys_freebsd_arm.s
@@ -89,8 +89,8 @@ TEXT runtime·exitThread(SB),NOSPLIT,$0-4
MOVW $0, R1
storeloop:
LDREX (R0), R4 // loads R4
- STREX R1, (R0), R1 // stores R2
- CMP $0, R1
+ STREX R1, (R0), R2 // stores R2
+ CMP $0, R2
BNE storeloop
MOVW $0, R0 // arg 1 long *state
MOVW $SYS_thr_exit, R7 The test passes. Also should memory barriers like in https://golang.org/src/runtime/internal/atomic/asm_arm.s atomic·armcas be added here as well? |
Ah, thanks. I looked up |
@paulzhol Want to see if https://golang.org/cl/70911 fixes the problem? |
Change https://golang.org/cl/70911 mentions this issue: |
@ianlancetaylor https://golang.org/cl/70911 works as well, what about the memory barriers? |
@aclements would know better but I don't think any memory barriers are required here because the only case that needs to read this field is holding |
Thanks for figuring that out! @ianlancetaylor is right that this doesn't exactly need a barrier. The ordered write is just there to be observed in a timely manner by another thread doing reaping and so that it doesn't get reordered with the last use of the stack. |
Thanks for explaining! |
It is triggered by the os test similarly to this builder log:
Attached a manually built os.test binary and it's core:
os.test_sigill.zip
The corefile itself is not usable under gdb 8.0.1:
While running the binary under gdb seems to work:
The text was updated successfully, but these errors were encountered: