Repository navigation
fix: compile the completion dump atomically - #396
Merged
Merged
Conversation
zcompile unlinks the shared .zcompdump.zwc and recreates it read-only in place, so shells starting together (a terminal restoring several tabs) race and fail with "can't write zwc file". Compile into a private file and rename it over the shared one.
mv -f moves the compiled file into a directory at the target instead of replacing it, so a directory there would collect a file on every rebuild.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
zcompileunlinks~/.zcompdump.zwcand recreates it read-only (0444) in place. When several shells start together (e.g. a terminal restoring tabs after login), one shell'sopen(O_CREAT)hits the file another just created and printscan't write zwc file..zcompdump.tmp.<pid>.<random>.zwcandmv -fit over the shared.zwc, for both the audited rebuild and the stale-bytecode recompile.compdumpalready writes atomically..zwcname..zcompdump.zwc:mv -fwould move the file into it instead of replacing it.Tests
TestNativeConcurrentDumpCompile: 8 concurrent zsh processes × 20 startups that each recompile; asserts no output and no leftover temp files. It fails 3/3 against the previous code and passes 5/5 with the fix.bash scripts/check.shlocally: everything passed exceptTestNeovimDAPConfiguration, which also fails on unmodifiedmainlocally (passes in main CI); unrelated to this change.