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

cmd/go: set .cache/go-build files as read-only #29697

mdempsky opened this issue Jan 11, 2019 · 0 comments

cmd/go: set .cache/go-build files as read-only #29697

mdempsky opened this issue Jan 11, 2019 · 0 comments


Copy link

@mdempsky mdempsky commented Jan 11, 2019

My understanding is that files in .cache/go-build are immutable and strongly named. If so, it might be worth setting them as read-only to help prevent cache corruption.

For example, as I mentioned on #24661, transitioning mdempsky/unconvert from go/loader to go/packages caused the go/token.File.Name() for cgo-processed files to start pointing into the go-build cache, whereas previously go/loader arranged for them to point to the original unprocessed files. The result was that the -apply flag silently started overwriting (and presumably corrupting) go-build cache entries.

Since I sloppily wrote unconvert to overwrite files in place, if the cache entries weren't writable, I believe it would have stopped this corruption. (Admittedly though I don't think this would help if I had properly implemented the write-to-temp-file-then-atomically-rename approach.)

For what it's worth, Git sets files in its .git/objects as read-only.

/cc @rsc

@mdempsky mdempsky added this to the Go1.12 milestone Jan 11, 2019
@bcmills bcmills modified the milestones: Go1.12, Go1.13 Jan 14, 2019
@bcmills bcmills added the GoCommand label Jan 14, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.