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

cmd/dist: go_bootstrap is broken on arm #9759

Closed
davecheney opened this issue Feb 3, 2015 · 7 comments
Closed

cmd/dist: go_bootstrap is broken on arm #9759

davecheney opened this issue Feb 3, 2015 · 7 comments
Milestone

Comments

@davecheney
Copy link
Contributor

cmd/go
./make.bash: line 153:  2242 Segmentation fault      (core dumped) "$GOTOOLDIR"/go_bootstrap clean -i std
Build complete, duration 4m48.860849034s. Result: error: exit status 139

The arm build broke somewhere around revision 2ec2931 but was obscured by #9734

@davecheney davecheney added this to the Go1.5 milestone Feb 3, 2015
@davecheney
Copy link
Contributor Author

I believe this is an alignment issue

rogram received signal SIGSEGV, Segmentation fault.
0x0009fcec in runtime.argv_index (argv=0xbefff7c9, i=525, ~r2=0x7061 <error: Cannot access memory at address 0x7061>) at /home/dfc/go/src/runtime/runtime1.go:45
45              return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*ptrSize))
(gdb) disassemble 
Dump of assembler code for function runtime.argv_index:
   0x0009fcd4 <+0>:     mov     r0, #0
   0x0009fcd8 <+4>:     ldr     r3, [sp, #4]
   0x0009fcdc <+8>:     ldr     r0, [sp, #8]
   0x0009fce0 <+12>:    lsl     r2, r0, #2
   0x0009fce4 <+16>:    mov     r0, #0
   0x0009fce8 <+20>:    add     r0, r3, r2
=> 0x0009fcec <+24>:    ldr     r1, [r0]
   0x0009fcf0 <+28>:    str     r1, [sp, #12]
   0x0009fcf4 <+32>:    add     pc, lr, #0
End of assembler dump.
(gdb) info registers 
r0             0xbefffffd       3204448253    <<< boom, not word aligned and we're using LDR
r1             0x7061   28769

@randall77
Copy link
Contributor

The argv pointer is not aligned. It gets set by runtime1.go:args(), and that gets called from asm_arm.s:rt0_go. So either that bad argv is from something getting clobbered, or the main argv started out as bad. We should probably add an assert to args() to be sure.

@davecheney
Copy link
Contributor Author

This code has not changed betwen g01.4 and tip. What I think is an issue is 5a is miscompiling MOVM.P.W [R0,R1],0(R13)

Compare the output from 5a compiling rt0_linux_arm.s

anda(~/go/src) % ../../go1.4/pkg/tool/linux_arm/5a -I cmd/ld -S runtime/rt0_linux_arm.s | grep -A5 ^_rt0_arm_linux1                                                      
_rt0_arm_linux1 t=1 nosplit size=16 value=0 args=0xffffffff80000000 locals=0x0 leaf
        0x0000 00000 (runtime/rt0_linux_arm.s:13)       TEXT    _rt0_arm_linux1+0(SB),4,$-4--2147483648
        0x0000 00000 (runtime/rt0_linux_arm.s:24)       MOVM.P.W        [R0,R1],0(R13)
        0x0004 00004 (runtime/rt0_linux_arm.s:45)       MOVW    $20,R7
        0x0008 00008 (runtime/rt0_linux_arm.s:46)       SWI     ,$0
        0x000c 00012 (runtime/rt0_linux_arm.s:56)       B       ,runtime.rt0_go(SB)

and tip

panda(~/go/src) % ../../go/pkg/tool/linux_arm/5a -I cmd/ld -S runtime/rt0_linux_arm.s | grep -A5 ^_rt0_arm_linux1
_rt0_arm_linux1 t=1 nosplit size=16 value=0 args=0xffffffff80000000 locals=0x0 leaf
        0x0000 00000 (runtime/rt0_linux_arm.s:13)       TEXT    _rt0_arm_linux1+0(SB),4,$-4--2147483648
        0x0000 00000 (runtime/rt0_linux_arm.s:24)       MOVM.P.W        ],0(R13)
        0x0004 00004 (runtime/rt0_linux_arm.s:45)       MOVW    $20,R7
        0x0008 00008 (runtime/rt0_linux_arm.s:46)       SWI     ,$0
        0x000c 00012 (runtime/rt0_linux_arm.s:56)       B       ,runtime.rt0_go(SB)

gdb also shows the same for a go1.4 binary

(gdb) disassemble/r _rt0_arm_linux1
Dump of assembler code for function _rt0_arm_linux1:
   0x000728b8 <+0>:     03 00 2d e9     push    {r0, r1}
   0x000728bc <+4>:     14 70 a0 e3     mov     r7, #20
   0x000728c0 <+8>:     00 00 00 ef     svc     0x00000000
   0x000728c4 <+12>:    04 d0 4d e2     sub     sp, sp, #4
   0x000728c8 <+16>:    52 62 ff eb     bl      0x4b218 <runtime.setup_auxv>
   0x000728cc <+20>:    04 d0 8d e2     add     sp, sp, #4
   0x000728d0 <+24>:    39 f5 ff ea     b       0x6fdbc <runtime.rt0_go>

and compiled with tip's 5a

(gdb) disassemble /r _rt0_arm_linux1
Dump of assembler code for function _rt0_arm_linux1:
   0x000c62dc <+0>:     00 00 2d e9     push    {}      ; <UNPREDICTABLE>
   0x000c62e0 <+4>:     14 70 a0 e3     mov     r7, #20
   0x000c62e4 <+8>:     00 00 00 ef     svc     0x00000000
   0x000c62e8 <+12>:    80 f3 ff ea     b       0xc30f0 <runtime.rt0_go>

note the push instruction is malformed so R1 which holds argv is not saved correctly.

I believe that the other MOVM encodings are simliarly affected

@minux
Copy link
Member

minux commented Feb 4, 2015 via email

@davecheney
Copy link
Contributor Author

I'm at 5ab3823c and I see

(gdb) disassemble _rt0_arm_linux1
Dump of assembler code for function _rt0_arm_linux1:
0x000c6db4 <+0>: push {} ;
0x000c6db8 <+4>: mov r7, #20
0x000c6dbc <+8>: svc 0x00000000
0x000c6dc0 <+12>: b 0xc3bc8 <runtime.rt0_go>
End of assembler dump.

@minux minux self-assigned this Feb 5, 2015
@minux minux closed this as completed in da4abda Feb 5, 2015
@davecheney davecheney reopened this Feb 5, 2015
@rsc rsc removed arch-arm labels Apr 10, 2015
@ianlancetaylor
Copy link
Contributor

What's the status of this issue? The ARM Linux builders seem to be working on the dashboard.

@rsc
Copy link
Contributor

rsc commented Jul 14, 2015

Running

GOOS=linux GOARCH=arm go tool asm -S rt0_linux_arm.s

I get:

_rt0_arm_linux1 t=1 nosplit size=16 value=0 args=0xffffffff80000000 locals=0x0 leaf
    0x0000 00000 (rt0_linux_arm.s:65)   TEXT    _rt0_arm_linux1(SB), 4, $-4
    0x0000 00000 (rt0_linux_arm.s:76)   MOVM.P.W    [R0,R1], (R13)
    0x0004 00004 (rt0_linux_arm.s:97)   MOVW    $20, R7
    0x0008 00008 (rt0_linux_arm.s:98)   SWI $0
    0x000c 00012 (rt0_linux_arm.s:108)  JMP runtime.rt0_go(SB)
    0x0000 03 00 2d e9 14 70 a0 e3 00 00 00 ef 00 00 00 ea  ..-..p..........
    rel 12+4 t=6 runtime.rt0_go+eafffffe

The instruction at 0x0000 is encoded as e92d0003, which is what was reported as the correct encoding, so I believe this is fixed (that and the arm builders are working).

@rsc rsc closed this as completed Jul 14, 2015
@golang golang locked and limited conversation to collaborators Jul 13, 2016
@rsc rsc unassigned minux Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants