Skip to content

fix(doctor): give the nvcc probe a directory this process created - #561

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/doctor-dryrun-temp-dir
Sep 4, 2026
Merged

fix(doctor): give the nvcc probe a directory this process created#561
Sunrisepeak merged 1 commit into
mainfrom
fix/doctor-dryrun-temp-dir

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Found reviewing #560 after it merged.

unreachable_device_stage() wrote its empty .cu into a fixed
mcpp-nvcc-dryrun under the shared temporary directory, and called
remove_all on it first so the name could be reused across runs. On a machine
with more than one user that is a predictable path someone else can create
first — and the remove_all a fixed name needs in order to be reusable is the
part that makes that matter, since the probe then writes through whatever it
found.

Two changes:

  • A random suffix, mcpp_nvcc_dryrun_<random_device>, which is the pattern
    src/build/prepare.cppm already uses for the p1689 scanner's scratch
    directory. No remove_all of a pre-existing path is needed once the name is
    fresh.
  • The gate reads create_directory's return value, not its error code.
    create_directory reports an already-existing directory by returning false
    without setting an error, so the previous if (ec) would have accepted
    exactly the case being avoided. Concurrent runs of mcpp self doctor are
    also no longer able to delete each other's scratch directory.

Both controls re-run against the rebuilt binary:

control occurrences of cannot reach its own back-end
working nvcc 0
nvcc copied to a directory holding no profile, first on PATH 1, naming cicc

mcpp test: 100 passed, 0 failed. No temporary directory is left behind after
either run.

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`.
@Sunrisepeak
Sunrisepeak merged commit a4043bf into main Sep 4, 2026
36 checks passed
@Sunrisepeak
Sunrisepeak deleted the fix/doctor-dryrun-temp-dir branch September 4, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants