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

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

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Probably not critical enough, we never supported running binaries under qemu user emulation before.