Skip to content
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: TestSegv/SegvInCgo failure with unexpected return pc for runtime.casgstatus on linux/arm #51353

bcmills opened this issue Feb 24, 2022 · 5 comments
NeedsFix release-blocker


Copy link

@bcmills bcmills commented Feb 24, 2022

--- FAIL: TestSegv (0.00s)
    --- FAIL: TestSegv/SegvInCgo (0.00s)
        testenv.go:361: [/workdir/tmp/go-build611327830/testprogcgo.exe SegvInCgo] exit status: exit status 2
        crash_cgo_test.go:609: SIGSEGV: segmentation violation
            PC=0x13da4 m=0 sigcode=0
            goroutine 19 [running]:
            runtime/internal/atomic.Xadd64(0x1, 0x200000000)
            	/workdir/go/src/runtime/internal/atomic/atomic_arm.s:262 +0x28 fp=0xc2675c sp=0xc26758 pc=0x13da4
            runtime: unexpected return pc for runtime.casgstatus called from 0x23b138
            stack: frame={sp:0xc2675c, fp:0xc2678c} stack=[0xc26000,0xc26800)
            0x00c266dc:  0x00000000  0x00000000  0x00000000  0x00000000 
            0x00c266ec:  0x00000000  0x00000000  0x00000000  0x00000000 
            0x00c266fc:  0x00000000  0x00000000  0x00000000  0x00000000 
            0x00c2670c:  0x00000000  0x00000000  0x00000000  0x00000000 
            0x00c2671c:  0x00000000  0x00000000  0x00000000  0x00000000 
            0x00c2672c:  0x00000000  0x00000000  0x00013634 <runtime/internal/atomic.goXadd64+0x000000f8>  0x0001b92c <runtime.(*timeHistogram).record+0x00000114> 
            0x00c2673c:  0x0024c3f0  0x00000000  0x00000001  0x00000001 
            0x00c2674c:  0x00000024  0x00000000  0x0024c3f0  0x00051084 <runtime.casgstatus+0x00000268> 
            0x00c2675c: <0x0023b138  0x00000001  0x00000000  0x00000002 
            0x00c2676c:  0x00050ecc <runtime.casgstatus+0x000000b0>  0x0007b208 <runtime.exitsyscall+0x00000108>  0x0023b138  0x00000000 
            0x00c2677c:  0x00000000  0x00000001  0x00057301 <runtime.goexit0+0x0000038d>  0x00000000 
            0x00c2678c: >0x00000000  0x00000000  0x00c21304  0x00000002 
            0x00c2679c:  0x00000003  0x000157ac <runtime.cgocall+0x000000a0>  0x00c824b0  0x00000003 
            0x00c267ac:  0x00000002  0x00c824b0  0x00c21300  0x0011afa8 <main._Cfunc_nop+0x0000002c> 
            0x00c267bc:  0x00125dc8  0x00c267e8  0x00c267e8  0x00c267e8 
            0x00c267cc:  0x00239e80  0x00121bd8 <main.SegvInCgo.func1+0x00000020>  0x00125dc8  0x00c267e8 
            0x00c267dc:  0x00c267e8  0x00c267e8  0x0007e8f4 <runtime.goexit+0x00000004>  0x00c8e080 
            0x00c267ec:  0x00000000  0x00000000  0x00000000  0x00000000 
            0x00c267fc:  0x00000000 
            runtime.casgstatus(0x0, 0xc21304, 0x2)
            	/workdir/go/src/runtime/proc.go:1020 +0x268 fp=0xc2678c sp=0xc2675c pc=0x51084
            created by main.SegvInCgo
            	/workdir/go/src/runtime/testdata/testprogcgo/segv.go:44 +0x74
            goroutine 1 [sleep]:
            	/workdir/go/src/runtime/time.go:194 +0x170
            	/workdir/go/src/runtime/testdata/testprogcgo/segv.go:56 +0xcc
            	/workdir/go/src/runtime/testdata/testprogcgo/main.go:34 +0x158
            trap    0x0
            error   0x0
            oldmask 0x0
            r0      0x1
            r1      0x23b138
            r2      0x0
            r3      0x23b138
            r4      0x0
            r5      0x0
            r6      0x0
            r7      0xc267bc
            r8      0x239e80
            r9      0xc02134
            r10     0xc824b0
            fp      0x6
            ip      0x0
            sp      0xc26758
            lr      0x1b92c
            pc      0x13da4
            cpsr    0x80870010
            fault   0x0
        crash_cgo_test.go:636: unexpectedly saw "runtime: " in output
FAIL	runtime	18.692s

Compare #50979, #39457. (CC @golang/runtime)

Copy link
Member Author

@bcmills bcmills commented Feb 24, 2022

Marking as release-blocker for Go 1.19 because linux/arm is a first class port.

@bcmills bcmills added this to the Go1.19 milestone Feb 24, 2022
@bcmills bcmills added release-blocker NeedsInvestigation labels Feb 24, 2022
Copy link

@prattmic prattmic commented Feb 24, 2022

It looks like (one of) the PCs in this trace is;l=262;drc=af1789a61c02fa769fcd4ab8addcbb9a160b987b.

I suspect that our traceback doesn't like that this is a direct jump rather than a branch-with-link.

cc @cherrymui fyi

Copy link

@cherrymui cherrymui commented Feb 25, 2022

I think the traceback code should be able to handle direct jump (i.e. tail call). The compiler generates tail calls in some wrappers as well.

However, that function has wrong SP delta. Will send a CL.

Copy link

@gopherbot gopherbot commented Feb 25, 2022

Change mentions this issue: runtime/internal/atomic: set SP delta correctly for 64-bit atomic functions on ARM

Copy link

@dmitshur dmitshur commented Mar 3, 2022

The CL fixing this was submitted while the tree was frozen for 1.18, before "internal/goversion: update Version to 1.19", so I'm going to remilestone this for Go1.18. If it shouldn't be included in Go 1.18, please comment.

@dmitshur dmitshur removed this from the Go1.19 milestone Mar 3, 2022
@dmitshur dmitshur added this to the Go1.18 milestone Mar 3, 2022
@dmitshur dmitshur added NeedsFix and removed NeedsInvestigation labels Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
NeedsFix release-blocker
Status: Done

No branches or pull requests

5 participants