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

x/mobile: binary generated by gomobile contains _ptrace which is a private API banned by Apple iOS #43302

Closed
libnat opened this issue Dec 21, 2020 · 4 comments
Labels
Milestone

Comments

@libnat
Copy link

@libnat libnat commented Dec 21, 2020

What version of Go are you using (go version)?

$ go version
go version go1.15.6 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/justintan/Library/Caches/go-build"
GOENV="/Users/justintan/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOOS="darwin"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cb/qs941gzn0sn5t40hb_5_cmqw0000gp/T/go-build437714881=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

GO111MODULE=off gomobile bind -v -ldflags="-s -w" -target=ios mypackage

It will generate an iOS framework. Then I submitted an iOS APP built with this framework to Apple Store for review. Got rejected because of using private API _ptrace.
I use nm to scan this package, found mypackage generated by gomobile contains _ptrace

Mypackage:go.o:                  U _ptrace
Mypackage:go.o: 0000000000080d00 t _syscall.libc_ptrace_trampoline
Mypackage:go.o: 0000000000ad4a40 s _syscall.libc_ptrace_trampoline.args_stackmap

Perhaps this issue is caused by go, not x/mobile.

If exec.Command("ls").Run() is contained in my package or dependencies, _ptrace can be found in the binary. I am not sure if this is the only reason.

import "os/exec"
// ...
exec.Command("ls").Run()

What did you expect to see?

No _ptrace in the iOS binary generated by gomobile, so our APP can pass AppleStore's checking.

What did you see instead?

_ptrace can be found in the iOS binary generated by gomobile

@gopherbot gopherbot added this to the Unreleased milestone Dec 21, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Dec 21, 2020

Change https://golang.org/cl/279481 mentions this issue: syscall: don't generate ptrace on iOS

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Dec 21, 2020

go version go1.15.6 darwin/amd64

@libnat are you sure you're using Go 1.15.6? Thanks.

The CL above should fix this for Go 1.16. But I don't think Go 1.15 has this problem.

@libnat
Copy link
Author

@libnat libnat commented Dec 21, 2020

@cherrymui Thanks for your reply.
I did install Go 1.16 beta. Once the binary got rejected by Apple, I removed Go 1.16 beta, and dir: ~/go/bin ~/go/pkg.
Then I installed Go 1.15.6 again, built gomobile/gobind with Go 1.15.6. I tried several times, but still got this issue.

@gopherbot gopherbot closed this in bc7e4d9 Dec 21, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Dec 22, 2020

Change https://golang.org/cl/279393 mentions this issue: unix: don't use ptrace on ios

gopherbot pushed a commit to golang/sys that referenced this issue Dec 23, 2020
Follow CL 279481 which did the same for package syscall.

For golang/go#43302.

Change-Id: I9fa7bec5712cf43fd7485225d4c21665c151defc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/279393
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants