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
GoCommand NeedsDecision


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 the NeedsDecision label Jan 11, 2019
@mdempsky mdempsky added this to the Go1.12 milestone Jan 11, 2019
@bcmills bcmills removed this from the Go1.12 milestone Jan 14, 2019
@bcmills bcmills added this to the Go1.13 milestone Jan 14, 2019
@bcmills bcmills added the GoCommand label Jan 14, 2019
@andybons andybons removed this from the Go1.13 milestone Jul 8, 2019
@andybons andybons added this to the Go1.14 milestone Jul 8, 2019
@rsc rsc removed this from the Go1.14 milestone Oct 9, 2019
@rsc rsc added this to the Backlog milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
GoCommand NeedsDecision
None yet

No branches or pull requests

4 participants