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
syscall: exec.Cmd.Run, os.Pipe broken on linux 2.6.23 / arm #30549
Comments
Assuming your analysis is correct, it seems there are two paths forward: either we fix |
(OT but I’d love to see a blog post on running Go programs on Kindles. I’ve always meant to do that and never got around to it. A mini tutorial would be awesome.) |
@ALTree AFAIR the minimum kernel version for linux/arm is 2.6.27. The reference to 2.6.23 is for linux on intel platforms. |
The problem is clear enough: your kernel doesn't support Another consideration is Android O, which has a seccomp filter. If I'm reading https://android.googlesource.com/platform/bionic/+/master/libc/SYSCALLS.TXT correctly, Android O systems only permit But we can try |
Change https://golang.org/cl/165217 mentions this issue: |
Change https://golang.org/cl/165297 mentions this issue: |
@josharian You wrote:
Try reading the Readme of his project, it’s pretty much what you asked for. |
@ianlancetaylor Thanks for fixing this! @josharian No blog of this stuff yet, but as zephyr mentioned I have a bit of a hacking log here. |
Follow CL 165217 which did this for package syscall. Android O seems to require Pipe to call the pipe2 system call. But kernel version 2.6.23 only supports pipe, not pipe2. So try pipe2 first, then fall back to pipe. Updates golang/go#30549 Change-Id: Icf21433fa046ff137c0265fa96410229def482f7 Reviewed-on: https://go-review.googlesource.com/c/sys/+/165297 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
What did you do?
I'm writing some software for old ereaders, specifically older Kindles. I've been cross compiling on macOS 10.14 using
env GOOS=linux GOARCH=arm GOARM=6 go ...
. This work great, except that I can't useexec.Command
or any other code that relies onsyscall.Pipe
as it returns afunction not implemented
error.I'm using
exec.Cmd.Run()
like so:However, this more minimal case will demonstrate the issue I am seeing:
When I run this code on the device, it fails with:
I think the cause is that
syscall.Pipe
is implemented usingpipe2
on linux/arm:It looks like pipe2 is only supported by linux 2.6.27. I'm on 2.6.23, which is listed as the minimum in the Go system requirements.
Interestingly, there is a comment to that recognizes this situation in src/os/pipe_linux.go:
The workaround above isn't going to make a difference, though, since
syscall.Pipe
still callspipe2
.You can see that there are 2
pipe2
syscalls when the program is run usingstrace
(the full output is included below):The same issue seems to be present in the
sys
package as well.What did you expect to see?
No error.
What did you see instead?
Solution
I have been working around this by modifying my Go distribution like so:
Changing the definition of
syscall.Pipe
to the following insrc/syscall/linux_arm.go
:And then adding the following to
src/syscall/zsyscall_linux_arm.go
(which I realize is normally autogenerated):I can see this OS not being officially supported as it is rather out of date, but that would be a bit of a shame since Go's cross compiling makes developing for this kind of older hardware a really nice experience.
System details
Device info:
Here is the output of running the executable with
strace
showing the failed attempt to use thepipe2
syscall:The text was updated successfully, but these errors were encountered: