Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Jan 2018 12:07:27 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 225105] Linux static golang binaries crash at startup
Message-ID:  <bug-225105-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D225105

            Bug ID: 225105
           Summary: Linux static golang binaries crash at startup
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: trasz@FreeBSD.org

Statically linked Linux binaries for golang seem to crash at startup, like
this:

% kdump=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
 88877 ktrace   RET   ktrace 0
 88877 ktrace   CALL  execve(0x7fffffffec95,0x7fffffffea08,0x7fffffffea18)
 88877 ktrace   NAMI  "./gofmt"
 88877 ktrace   PFLT  0x617000 0x2<VM_PROT_WRITE>
 88877 ktrace   PRET  KERN_SUCCESS
 88877 ktrace   PFLT  0x7fffffffe000 0x2<VM_PROT_WRITE>
 88877 ktrace   PRET  KERN_SUCCESS
 88877 ktrace   PFLT  0x7fffffffd000 0x2<VM_PROT_WRITE>
 88877 ktrace   PRET  KERN_SUCCESS
 88877 gofmt    RET   linux_execve 0
 88877 gofmt    PFLT  0x618000 0x2<VM_PROT_WRITE>
 88877 gofmt    PRET  KERN_SUCCESS
 88877 gofmt    PFLT  0x636000 0x2<VM_PROT_WRITE>
 88877 gofmt    PRET  KERN_SUCCESS
 88877 gofmt    CALL  linux_arch_prctl(0x1002,0x618be8)
 88877 gofmt    RET   linux_arch_prctl 0
 88877 gofmt    PSIG  SIGSEGV SIG_DFL code=3DSEGV_MAPERR
 88877 gofmt    NAMI  "gofmt.core"

% gdb801 ./gofmt=20=20=20=20=20=20=20=20=20=20=20=20=20=20
GNU gdb (GDB) 8.0.1 [GDB v8.0.1 for FreeBSD]
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.htm=
l>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./gofmt...done.
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /usr/home/en322/aosp/prebuilts/go/linux-x86/bin/gofmt.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) run
Starting program: /usr/home/en322/aosp/prebuilts/go/linux-x86/bin/gofmt=20

Program received signal SIGSEGV, Segmentation fault.
runtime.rt0_go () at prebuilts/go/linux-x86/src/runtime/asm_amd64.s:149
149     prebuilts/go/linux-x86/src/runtime/asm_amd64.s: No such file or
directory.
(gdb) where
#0  runtime.rt0_go () at prebuilts/go/linux-x86/src/runtime/asm_amd64.s:149
#1  0x0000000000000000 in ?? ()
(gdb) disass
Dump of assembler code for function runtime.rt0_go:
   0x0000000000453510 <+0>:     mov    %rdi,%rax
   0x0000000000453513 <+3>:     mov    %rsi,%rbx
   0x0000000000453516 <+6>:     sub    $0x27,%rsp
   0x000000000045351a <+10>:    and    $0xfffffffffffffff0,%rsp
   0x000000000045351e <+14>:    mov    %rax,0x10(%rsp)
   0x0000000000453523 <+19>:    mov    %rbx,0x18(%rsp)
   0x0000000000453528 <+24>:    lea    0x1c5151(%rip),%rdi        # 0x618680
<runtime.g0>
   0x000000000045352f <+31>:    lea    -0xff98(%rsp),%rbx
   0x0000000000453537 <+39>:    mov    %rbx,0x10(%rdi)
   0x000000000045353b <+43>:    mov    %rbx,0x18(%rdi)
   0x000000000045353f <+47>:    mov    %rbx,(%rdi)
   0x0000000000453542 <+50>:    mov    %rsp,0x8(%rdi)
   0x0000000000453546 <+54>:    xor    %eax,%eax
   0x0000000000453548 <+56>:    cpuid
   0x000000000045354a <+58>:    mov    %eax,%esi
   0x000000000045354c <+60>:    cmp    $0x0,%eax
   0x000000000045354f <+63>:    je     0x453656 <runtime.rt0_go+326>
   0x0000000000453555 <+69>:    cmp    $0x756e6547,%ebx
   0x000000000045355b <+75>:    jne    0x45357b <runtime.rt0_go+107>
   0x000000000045355d <+77>:    cmp    $0x49656e69,%edx
   0x0000000000453563 <+83>:    jne    0x45357b <runtime.rt0_go+107>
   0x0000000000453565 <+85>:    cmp    $0x6c65746e,%ecx
   0x000000000045356b <+91>:    jne    0x45357b <runtime.rt0_go+107>
   0x000000000045356d <+93>:    movb   $0x1,0x1e2ed0(%rip)        # 0x636444
<runtime.isIntel>
   0x0000000000453574 <+100>:   movb   $0x1,0x1e2ecd(%rip)        # 0x636448
<runtime.lfenceBeforeRdtsc>
   0x000000000045357b <+107>:   mov    $0x1,%eax
   0x0000000000453580 <+112>:   cpuid
   0x0000000000453582 <+114>:   mov    %eax,0x1e2f1c(%rip)        # 0x6364a4
<runtime.processorVersionInfo>
   0x0000000000453588 <+120>:   test   $0x4000000,%edx
   0x000000000045358e <+126>:   setne  0x1e2ebd(%rip)        # 0x636452
<runtime.support_sse2>
   0x0000000000453595 <+133>:   test   $0x200,%ecx
   0x000000000045359b <+139>:   setne  0x1e2eb3(%rip)        # 0x636455
<runtime.support_ssse3>
   0x00000000004535a2 <+146>:   test   $0x80000,%ecx
   0x00000000004535a8 <+152>:   setne  0x1e2ea4(%rip)        # 0x636453
<runtime.support_sse41>
   0x00000000004535af <+159>:   test   $0x100000,%ecx
   0x00000000004535b5 <+165>:   setne  0x1e2e98(%rip)        # 0x636454
<runtime.support_sse42>
   0x00000000004535bc <+172>:   test   $0x800000,%ecx
   0x00000000004535c2 <+178>:   setne  0x1e2e88(%rip)        # 0x636451
<runtime.support_popcnt>
   0x00000000004535c9 <+185>:   test   $0x2000000,%ecx
   0x00000000004535cf <+191>:   setne  0x1e2e74(%rip)        # 0x63644a
<runtime.support_aes>
   0x00000000004535d6 <+198>:   test   $0x8000000,%ecx
   0x00000000004535dc <+204>:   setne  0x1e2e6d(%rip)        # 0x636450
<runtime.support_osxsave>
   0x00000000004535e3 <+211>:   test   $0x10000000,%ecx
   0x00000000004535e9 <+217>:   setne  0x1e2e5b(%rip)        # 0x63644b
<runtime.support_avx>
   0x00000000004535f0 <+224>:   cmp    $0x7,%esi
   0x00000000004535f3 <+227>:   jl     0x453632 <runtime.rt0_go+290>
   0x00000000004535f5 <+229>:   mov    $0x7,%eax
   0x00000000004535fa <+234>:   xor    %ecx,%ecx
   0x00000000004535fc <+236>:   cpuid
   0x00000000004535fe <+238>:   test   $0x8,%ebx
   0x0000000000453604 <+244>:   setne  0x1e2e42(%rip)        # 0x63644d
<runtime.support_bmi1>
   0x000000000045360b <+251>:   test   $0x20,%ebx
   0x0000000000453611 <+257>:   setne  0x1e2e34(%rip)        # 0x63644c
<runtime.support_avx2>
   0x0000000000453618 <+264>:   test   $0x100,%ebx
   0x000000000045361e <+270>:   setne  0x1e2e29(%rip)        # 0x63644e
<runtime.support_bmi2>
   0x0000000000453625 <+277>:   test   $0x200,%ebx
   0x000000000045362b <+283>:   setne  0x1e2e1d(%rip)        # 0x63644f
<runtime.support_erms>
   0x0000000000453632 <+290>:   cmpb   $0x1,0x1e2e17(%rip)        # 0x636450
<runtime.support_osxsave>
   0x0000000000453639 <+297>:   jne    0x453648 <runtime.rt0_go+312>
   0x000000000045363b <+299>:   xor    %ecx,%ecx
   0x000000000045363d <+301>:   xgetbv
   0x0000000000453640 <+304>:   and    $0x6,%eax
   0x0000000000453643 <+307>:   cmp    $0x6,%eax
   0x0000000000453646 <+310>:   je     0x453656 <runtime.rt0_go+326>
   0x0000000000453648 <+312>:   movb   $0x0,0x1e2dfc(%rip)        # 0x63644b
<runtime.support_avx>
   0x000000000045364f <+319>:   movb   $0x0,0x1e2df6(%rip)        # 0x63644c
<runtime.support_avx2>
   0x0000000000453656 <+326>:   mov    0x1c43cb(%rip),%rax        # 0x617a28
<_cgo_init>
---Type <return> to continue, or q <return> to quit---
   0x000000000045365d <+333>:   test   %rax,%rax
   0x0000000000453660 <+336>:   je     0x453688 <runtime.rt0_go+376>
   0x0000000000453662 <+338>:   mov    %rdi,%rcx
   0x0000000000453665 <+341>:   lea    0x1bc4(%rip),%rsi        # 0x455230
<setg_gcc>
   0x000000000045366c <+348>:   callq  *%rax
   0x000000000045366e <+350>:   lea    0x1c500b(%rip),%rcx        # 0x618680
<runtime.g0>
   0x0000000000453675 <+357>:   mov    (%rcx),%rax
   0x0000000000453678 <+360>:   add    $0x370,%rax
   0x000000000045367e <+366>:   mov    %rax,0x10(%rcx)
   0x0000000000453682 <+370>:   mov    %rax,0x18(%rcx)
   0x0000000000453686 <+374>:   jmp    0x4536b7 <runtime.rt0_go+423>
   0x0000000000453688 <+376>:   lea    0x1c5551(%rip),%rdi        # 0x618be0
<runtime.m0+96>
   0x000000000045368f <+383>:   callq  0x457940 <runtime.settls>
=3D> 0x0000000000453694 <+388>:   movq   $0x123,%fs:0xfffffffffffffff8
   0x00000000004536a1 <+401>:   mov    0x1c5538(%rip),%rax        # 0x618be0
<runtime.m0+96>
   0x00000000004536a8 <+408>:   cmp    $0x123,%rax
   0x00000000004536ae <+414>:   je     0x4536b7 <runtime.rt0_go+423>
   0x00000000004536b0 <+416>:   mov    %eax,0x0
   0x00000000004536b7 <+423>:   lea    0x1c4fc2(%rip),%rcx        # 0x618680
<runtime.g0>
   0x00000000004536be <+430>:   mov    %rcx,%fs:0xfffffffffffffff8
   0x00000000004536c7 <+439>:   lea    0x1c54b2(%rip),%rax        # 0x618b80
<runtime.m0>
   0x00000000004536ce <+446>:   mov    %rcx,(%rax)
   0x00000000004536d1 <+449>:   mov    %rax,0x30(%rcx)
   0x00000000004536d5 <+453>:   cld=20=20=20=20
   0x00000000004536d6 <+454>:   callq  0x4378c0 <runtime.check>
   0x00000000004536db <+459>:   mov    0x10(%rsp),%eax
   0x00000000004536df <+463>:   mov    %eax,(%rsp)
   0x00000000004536e2 <+466>:   mov    0x18(%rsp),%rax
   0x00000000004536e7 <+471>:   mov    %rax,0x8(%rsp)
   0x00000000004536ec <+476>:   callq  0x4372c0 <runtime.args>
   0x00000000004536f1 <+481>:   callq  0x4267a0 <runtime.osinit>
   0x00000000004536f6 <+486>:   callq  0x42b1f0 <runtime.schedinit>
   0x00000000004536fb <+491>:   lea    0x11f8e6(%rip),%rax        # 0x572fe8
<runtime.mainPC>
   0x0000000000453702 <+498>:   push   %rax
   0x0000000000453703 <+499>:   pushq  $0x0
   0x0000000000453705 <+501>:   callq  0x431b00 <runtime.newproc>
   0x000000000045370a <+506>:   pop    %rax
   0x000000000045370b <+507>:   pop    %rax
   0x000000000045370c <+508>:   callq  0x42d0b0 <runtime.mstart>
   0x0000000000453711 <+513>:   movl   $0xf1,0xf1
   0x000000000045371c <+524>:   retq=20

That part of the go runtime source looks like this:

needtls:
#ifdef GOOS_plan9
        // skip TLS setup on Plan 9
        JMP ok
#endif
#ifdef GOOS_solaris
        // skip TLS setup on Solaris
        JMP ok
#endif

        LEAQ    runtime=C2=B7m0+m_tls(SB), DI
        CALL    runtime=C2=B7settls(SB)

        // store through it, to make sure it works
        get_tls(BX)
        MOVQ    $0x123, g(BX)
        MOVQ    runtime=C2=B7m0+m_tls(SB), AX
        CMPQ    AX, $0x123
        JEQ 2(PC)
        MOVL    AX, 0   // abort
ok:

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-225105-8>