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: qemu-arm fails to emulate go user programs #13024

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

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

arges opened this issue Oct 22, 2015 · 16 comments

Comments

@arges
Copy link

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 qemu-arm fails to emulate go user programs runtime: qemu-arm fails to emulate go user programs Oct 22, 2015
@rsc
Copy link
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
@gopherbot
Copy link
Contributor

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

@rsc rsc closed this as completed in d106750 Nov 12, 2015
@davecheney
Copy link
Contributor

Could this be backported to 1.5.2 ?

@minux
Copy link
Member

minux commented Nov 12, 2015 via email

@rsc
Copy link
Contributor

rsc commented Nov 12, 2015 via email

@davecheney
Copy link
Contributor

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
@streamnsight
Copy link

👍 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

@rsc
Copy link
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
Copy link

@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.

@mwhudson
Copy link
Contributor

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.

@gopherbot
Copy link
Contributor

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

aclements pushed a commit that referenced this issue Nov 17, 2015
…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 <[email protected]>
Reviewed-on: https://go-review.googlesource.com/16986
Run-TryBot: Austin Clements <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
@arges
Copy link
Author

arges commented Nov 17, 2015

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

@luxas
Copy link

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

@davecheney
Copy link
Contributor

@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
Copy link

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.

@minux
Copy link
Member

minux commented Dec 15, 2015 via email

@golang golang 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.
Projects
None yet
Development

No branches or pull requests

8 participants