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

os: new runtime.GOOS of "ios" breaks os.User*Dir functions on GoTip for Go1.16 #42878

Closed
whereswaldon opened this issue Nov 29, 2020 · 2 comments
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin release-blocker
Milestone

Comments

@whereswaldon
Copy link
Contributor

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

$ go version
go version devel +926994fd7c Thu Nov 26 21:10:09 2020 +0000 darwin/amd64

Does this issue reproduce with the latest release?

No, it's only reproducible in TIP

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/christopherwaldon/Library/Caches/go-build"
GOENV="/Users/christopherwaldon/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/christopherwaldon/Code/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/christopherwaldon/Code/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/christopherwaldon/Code/builds/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/christopherwaldon/Code/builds/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="devel +926994fd7c Thu Nov 26 21:10:09 2020 +0000"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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/1y/0b2jj2p97bn5003_cxtrxrg40000gn/T/go-build007027862=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

An application that I maintain targets iOS, and I compiled it using the master branch of Go in order to get around the CFLAGS breakage that won't be fixed until the Go 1.15.6 release. It always crashed at startup when build with the master branch, and I saw this in the log:

Nov 29 16:24:06 kernel(Sandbox)[0] <Error>: Sandbox: Sprig(481) deny(1) file-write-create /private/var/mobile/Containers/Data/Application/0A1A0815-9F18-49E3-89C3-F99B6EFE1C9A/.config

The fact that this wasn't broken before, and that it ends with the incorrect path for the configuration directory led to to investigate where this path was coming from. It's emitted by os.UserConfigDir. After some digging, I realized that the logic in this and related OS functions do not handle the new runtime.GOOS value of ios.

To reproduce, build any code targeting iOS and invoke those functions. You'll fall through to the XDG case instead of the expected GOOS=darwin, GOARCH=arm64 ones.

I believe this was introduced by the changes here.

What did you expect to see?

I expected to be returned the correct config directory path.

What did you see instead?

I got the XDG-style config path instead, which the iOS sandbox prohibits writing to.

I already have a fix for this, and I'll open a PR right after this issue to propose the tweak to fix it. It's really straightforward, I think.

whereswaldon added a commit to whereswaldon/go that referenced this issue Nov 29, 2020
Separating iOS into its own runtime constant broke the logic
here to derive the correct home, cache, and config directories
on iOS devices.

Fixes golang#42878
@odeke-em odeke-em changed the title new runtime.GOOS of "ios" breaks os.User*Dir functions in master branch os: new runtime.GOOS of "ios" breaks os.User*Dir functions on GoTip for Go1.16 Nov 29, 2020
@gopherbot
Copy link

Change https://golang.org/cl/273947 mentions this issue: os: return proper user directories on iOS

@odeke-em
Copy link
Member

Thank you for the bug report @whereswaldon and congrats on opening your first issue, great to catch you here!

Nice catch, I shall kindly cc some interested parties @bradfitz @kevinburke @ianlancetaylor @eliasnaur.

@odeke-em odeke-em added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 29, 2020
@odeke-em odeke-em added this to the Go1.16 milestone Nov 29, 2020
whereswaldon added a commit to whereswaldon/go that referenced this issue Nov 29, 2020
Separating iOS into its own runtime constant broke the logic
here to derive the correct home, cache, and config directories
on iOS devices.

Fixes golang#42878
whereswaldon added a commit to whereswaldon/go that referenced this issue Nov 29, 2020
This change adds GOOS=ios to the various User*Dir logic. It is
necessary because after golang#38485 was implemented, we isolated
GOOS=ios from GOOS=darwin and forgot to carry over the logic too,
to derive the appropriate home, cache and config directories on
iOS devices.

Updates golang#38485
Fixes golang#42878
@bcmills bcmills added mobile Android, iOS, and x/mobile OS-Darwin release-blocker labels Nov 30, 2020
@golang golang locked and limited conversation to collaborators Nov 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge mobile Android, iOS, and x/mobile NeedsFix The path to resolution is known, but the work has not been done. OS-Darwin release-blocker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants