i386 Go programs crash on amd64

Konstantin Belousov kostikbel at gmail.com
Mon May 26 13:45:10 UTC 2014


On Mon, May 26, 2014 at 09:36:22PM +1000, Peter Jeremy wrote:
> On 2014-May-24 10:41:01 +0300, Konstantin Belousov <kostikbel at gmail.com> wrote:
> >> >Provide the minimal test case.
> >> 
> >> The following go program, compiled on i386 and run on amd64 will die
> >> with a segmentation violation or bus error:
> >> -------
> >> package main
> >> 
> >> import "fmt"
> >> 
> >> func main() {
> >>         fmt.Println("Hello World")
> >> }
> >> -------
> >No, this is not consumable.
> >
> >I need a self-contained minimal example written in C/asm.
> 
> Actually, I've found that
> --------
> package main
> import "syscall"
> func main() { syscall.Write(1, []byte("Hello World\n")) }
> --------
> also crashes ~66 syscalls after the first sysarch(2) call.  That
> reduces the binary to 520K (go reports this is 50K lines of assembler).
> 
> >If this is too hard to produce, give the the self-contained
> >binary, again as small as possible (small by comparing the
> >number of syscalls before the issue manifests itself).
> 
> I've uploaded the source, binary and disassembly to
> freefall:~peterj/write{.go,,.S} (and verified it crashes).
> 
> If I get time, I'll see if I can strip some of the support code out of
> Go to shrink it further.

What exactly do you mean by 'crashing' ? I see some spills from
(probably) Go runtime. I am not sure that this is something which should
be looked at from the kernel side, at least initially. E.g., the 32bit
binaries on amd64 have stack starting near the top of the address space,
i.e. 4G - some amount. Could this be a problem for the Go ?

What I see is:

pooma% ./write-go                                   ~/build/bsd/DEV/stuff/tests
runtime: newstack called from g=0x382d5500
        m=0x382e5800 m->curg=0x0 m->g0=0x382d55a0 m->gsignal=0x382d5500
fatal error: runtime: wrong goroutine in newstack

runtime stack:
runtime.throw(0x8096910)
        /usr/local/go/src/pkg/runtime/panic.c:464 +0x5f
runtime.newstack()
        /usr/local/go/src/pkg/runtime/stack.c:212 +0x90
runtime.morestack()
        /usr/local/go/src/pkg/runtime/asm_386.s:246 +0x5e
Hello World

goroutine 1 [panicwait]:
runtime.park(0x0, 0x0, 0x8097b74)
        /usr/local/go/src/pkg/runtime/proc.c:1342 +0x59
runtime.main()
        /usr/local/go/src/pkg/runtime/proc.c:229 +0x125
runtime.goexit()
        /usr/local/go/src/pkg/runtime/proc.c:1394
[1]    1537 segmentation fault (core dumped)  ./write-go
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20140526/d9e4c28b/attachment.sig>


More information about the freebsd-amd64 mailing list