fix(doctor): give the nvcc probe a directory this process created - #561
Merged
Conversation
The probe wrote into a fixed `mcpp-nvcc-dryrun` under the shared temporary directory, and removed whatever was already there so the name could be reused. On a machine with more than one user that name is a path someone else can create first, and the removal is what makes that worth caring about. It now takes a random suffix, which is the pattern the p1689 scanner already uses, and it checks create_directory's return value rather than the error code: an existing directory is reported by returning false without setting an error, and entering a directory this process did not create is the case being avoided. Both controls re-run: with a working nvcc the warning does not appear; with nvcc copied to a directory holding no profile it appears and names `cicc`.
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.
Found reviewing #560 after it merged.
unreachable_device_stage()wrote its empty.cuinto a fixedmcpp-nvcc-dryrununder the shared temporary directory, and calledremove_allon it first so the name could be reused across runs. On a machinewith more than one user that is a predictable path someone else can create
first — and the
remove_alla fixed name needs in order to be reusable is thepart that makes that matter, since the probe then writes through whatever it
found.
Two changes:
mcpp_nvcc_dryrun_<random_device>, which is the patternsrc/build/prepare.cppmalready uses for the p1689 scanner's scratchdirectory. No
remove_allof a pre-existing path is needed once the name isfresh.
create_directory's return value, not its error code.create_directoryreports an already-existing directory by returning falsewithout setting an error, so the previous
if (ec)would have acceptedexactly the case being avoided. Concurrent runs of
mcpp self doctorarealso no longer able to delete each other's scratch directory.
Both controls re-run against the rebuilt binary:
cannot reach its own back-endciccmcpp test: 100 passed, 0 failed. No temporary directory is left behind aftereither run.