runtime: qemu-arm fails to emulate go user programs #13024

Closed
arges opened this Issue Oct 22, 2015 · 16 comments

Comments

Projects
None yet
8 participants

arges commented Oct 22, 2015

qemu-arm fails to emulate go user programs due to how qemu handles certain signals.

The original issue/diff that seems to solve the issue is here:
https://codereview.appspot.com/124900043/diff/60001/src/pkg/runtime/os_linux.c

The qemu code is here:
http://git.qemu.org/?p=qemu.git;a=blob;f=linux-user/signal.c;h=1141054be2170128d6f7a340b41484b49a255936;hb=HEAD#l82

Test Case:

Build this on an non-arm platform such as x86.

test.go:

package main

import "fmt"

func main() {
 fmt.Println("Hi")
}
  1. GOARCH=arm go build test.go
  2. qemu-arm test

This will fail with the following error:

qemu-arm test
fatal error: rt_sigaction failure

runtime stack:
runtime.throw(0x106d68, 0x14)
    /usr/lib/go/src/runtime/panic.go:527 +0x78
runtime.setsig(0x40, 0x6f8b0, 0x1)
    /usr/lib/go/src/runtime/os1_linux.go:297 +0x148
runtime.initsig()
    /usr/lib/go/src/runtime/signal1_unix.go:67 +0x180
runtime.mstart1()
    /usr/lib/go/src/runtime/proc1.go:717 +0xd4
runtime.mstart()
    /usr/lib/go/src/runtime/proc1.go:691 +0x84

goroutine 1 [runnable]:
runtime.main()
    /usr/lib/go/src/runtime/proc.go:28
runtime.goexit()
    /usr/lib/go/src/runtime/asm_arm.s:1036 +0x4

Testing with the aforementioned patch solves the issue, but I'm unsure its the best approach to solving this. I can re-propose that patch if there isn't a better solution, but this would be a very useful feature for using qemu user space emulation with go.

--chris

@rakyll rakyll changed the title from qemu-arm fails to emulate go user programs to runtime: qemu-arm fails to emulate go user programs Oct 22, 2015

Contributor

rsc commented Oct 23, 2015

/cc @minux who wrote CL 124900043.

I'm not sure how/why that code got lost/reverted. It seems fine to put in again.

@rsc rsc added this to the Go1.6 milestone Oct 23, 2015

CL https://golang.org/cl/16853 mentions this issue.

@rsc rsc closed this in d106750 Nov 12, 2015

Contributor

davecheney commented Nov 12, 2015

Could this be backported to 1.5.2 ?

Member

minux commented Nov 12, 2015

Contributor

rsc commented Nov 12, 2015

Contributor

davecheney commented Nov 12, 2015

Thanks @rsc. Canonical have gone through a lot of internal bureaucratic pain to get up to Go 1.5, if this patch could make it into 1.5.2 that would be much appreciated.

@rsc rsc modified the milestones: Go1.5.2, Go1.6 Nov 12, 2015

👍 for the patch
/cc @minux
Can someone tell which go version had the original patch? or when 1.5.2 is scheduled to be released?
I'm having the same problem trying to compile code in qemu

thanks

Contributor

rsc commented Nov 16, 2015

No released Go version has had this patch, as far as I understand. Go 1.5.2 should be out by the end of the calendar year, probably sooner.

@streamnsight streamnsight referenced this issue in luxas/kubernetes-on-arm Nov 16, 2015

Closed

question: how does it work? #16

@rsc thanks
I thought I understood the patch was there but was 'reversed' at some point. the very first link mentioned by @arges seems to be it, but there is no clear indication of what the version was at the time.

Contributor

mwhudson commented Nov 16, 2015

AIUI the fix was committed to the C version of the runtime on the dev.power64, but I don't think it ever got to master. Perhaps it got lost as part of the transition of the runtime to pure go? Doesn't really matter now anyway.

CL https://golang.org/cl/16986 mentions this issue.

aclements added a commit that referenced this issue Nov 17, 2015

[release-branch.go1.5] runtime: ignore rt_sigaction error if it is fo…
…r SIGRTMAX

A forward port of https://codereview.appspot.com/124900043/ which somehow
got lost somewhere.

Fixes #13024

Change-Id: Iab128899e65c51d90f6704e3e1b2fc9326e3a1c2
Reviewed-on: https://go-review.googlesource.com/16853
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-on: https://go-review.googlesource.com/16986
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>

arges commented Nov 17, 2015

@streamnsight FWIW I originally reproduced this issue in go1.5.1

luxas commented Dec 15, 2015

I compiled a binary on ARM (etcd) with latest go1.5.2.
However, now this issue came up instead (on amd64):

# On host machine
$ qemu-arm-static etcd
Segmentation fault (core dumped)

# Running in docker
$ etcd
/build/buildd/qemu-2.0.0+dfsg/tcg/optimize.c:362: tcg fatal error
Aborted (core dumped)

$ etcd
/build/buildd/qemu-2.0.0+dfsg/tcg/tcg.c:1693: tcg fatal error
Aborted (core dumped)

I'm using https://github.com/moul/docker-binfmt-register for running ARM docker images on amd64
I'll try to reproduce what @arges did

Contributor

davecheney commented Dec 15, 2015

@luxas this is probably a different issue. Please open a new issue, but note that qemu is not reliable when running go programs. qemu's emulation is too glibc specific.

luxas commented Dec 15, 2015

Yep, I'm fine with creating a new issue. Just said it here first, so you guys know about it.

Member

minux commented Dec 15, 2015

@giggio giggio referenced this issue in travis-ci/travis-ci Dec 11, 2016

Closed

Support Android / Arm #3376

@gopherbot gopherbot locked and limited conversation to collaborators Dec 14, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.