Skip to content

fix(tauri): make temp file names collision-proof - #176

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/temp-path-collisions
Jun 25, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/temp-path-collisions

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Bug R3 from the latent-bug audit.

Problem

temp_path named files fiberpath-{millis}.{ext} — millisecond-only entropy. Two same-extension commands landing in the same millisecond (validate/preview fire on edits; withRetry can re-fire quickly) produced the same path, so one call's TempFile::Drop deleted the other's file mid-use, or they clobbered each other's contents → intermittent "file not found" / corrupted plot or validation output.

Fix

Include the process id and a monotonic AtomicU64 counter in the name (fiberpath-{pid}-{millis}-{seq}.{ext}), guaranteeing uniqueness within and across processes.

Test (runs in CI)

temp_path_is_unique_under_rapid_calls collects 1000 rapid temp_path results into a set and asserts all 1000 are distinct — reliably fails on the old millisecond-only name (1000 calls share milliseconds), passes with the counter.

temp_path used a millisecond-only name (fiberpath-{millis}.{ext}), so two
same-extension commands in the same millisecond (e.g. validate/preview firing
on edits, or withRetry re-firing) produced the same path — one call's
TempFile::Drop then deleted the other's file, or they clobbered each other,
causing spurious 'file not found' / corrupted output. Add the PID and a
monotonic atomic counter to the name. Test asserts 1000 rapid calls are
all unique.
@CameronBrooks11
CameronBrooks11 merged commit 579ef2c into main Jun 25, 2026
15 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/temp-path-collisions branch June 25, 2026 22:30
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.

1 participant