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: go gets stuck when running in a FreeBSD jail #15044

Closed
galdor opened this issue Mar 31, 2016 · 6 comments
Closed

runtime: go gets stuck when running in a FreeBSD jail #15044

galdor opened this issue Mar 31, 2016 · 6 comments

Comments

@galdor
Copy link

galdor commented Mar 31, 2016

Go version

1.6 (official freebsd pkg 1.6,1)

System

FreeBSD 10.2 (10.2-RELEASE-p13).
Commands executed in a jail.

Problem

Running any kind of go command (even something as simple as go --help) in a jail gets stuck and has to be killed with SIGKILL. There is no such problem when running go outside of a jail.

Trace

Running ktrace go --help:

 72810 go       CALL  sigaction(SIG 32,0x7fffffffea18,0)
 72810 go       RET   sigaction 0
 72810 go       CALL  clock_gettime(0x4,0xc820020750)
 72810 go       RET   clock_gettime 0
 72810 go       CALL  sigprocmask(SIG_SETMASK,0x7fffffffe970,0x7fffffffe9a0)
 72810 go       RET   sigprocmask 0
 72810 go       CALL  _umtx_op(0x8010ad330,0x11,0,0,0)

Full trace: go-help-ktrace.txt

I have the exact same problem when executing in a jail a binary built with go build outside a jail.

This is the first time we are trying to run our Go software on FreeBSD, so I have no idea whether it is a FreeBSD problem or a Go problem. We did not have any problem when our software was in C, and have been using FreeBSD jails for some time now.

@ianlancetaylor
Copy link
Contributor

Does every Go program fail in this was, or just the go tool itself? For example, you should be able to use the go tool outside of a jail to build a simple hello, world program. Does that program fail when run in a jail?

What kind of processor are you running on?

I actually don't see how that ktrace output is possible. The Go runtime only ever passes 0xf and 0x10 to _umtx_op. I don't know where the 0x11 is coming from.

@ianlancetaylor ianlancetaylor changed the title go gets stuck when running in a FreeBSD jail runtime: go gets stuck when running in a FreeBSD jail Mar 31, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Mar 31, 2016
@brknstrngz
Copy link

Is the userland in your jail in sync with your kernel?

@galdor
Copy link
Author

galdor commented Apr 1, 2016

The architecture is amd64; the CPU is an Intel Core i5 750.
Both the userland and the base system and the jail are 10.2-RELEASE-p13.

I tried with a simple hello world program.

  • Building it out of the jail works. Running the generated executable in the jail works.
  • Building it in the jail results in the go runtime getting stuck the same way.

Finally I tried a hello world program using the C package:

package main

// #include <stdio.h>
//
// static void helloWorld() {
//     printf("hello world\n");
// }
import "C"

func main() {
        C.helloWorld()
}

Building it out of the jail, then running it in the jail results in it getting stuck.
Our software also uses C, and also gets stuck in the same situation.
Does the go runtime use C ? If yes, there could be something wrong with C when running in a jail.

_umtx_op seems to be pthread-related, and afaik, cgo uses pthreads. This would make sense.

@ianlancetaylor
Copy link
Contributor

The Go runtime itself does not use C. However, many Go programs do use C. Go makes system calls directly, including to _umtx_op. _umtx_op is related to threads. If the jail does not support threads, then no substantial Go program is going to work inside it.

@galdor
Copy link
Author

galdor commented Apr 1, 2016

There is afaik nothing in jails that prevent using threads in any way. I already ran multithreaded applications in jails without any problem.

However a quick Google search shows that there are various people having this kind of problems with applications using pthreads. I'm not sure how to fix this problem.

@ianlancetaylor
Copy link
Contributor

Thanks. I'm going to close this issue because I don't think there is anything we can do on the Go side to fix it. Please reopen if there is something we can change in Go to make it work.

@golang golang locked and limited conversation to collaborators Apr 2, 2017
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

4 participants