-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Closed
Copy link
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
As discovered by @ehuss in rust-lang/cargo#10120, a Cargo test is intermittently failing on Windows because a source file generated by Rustdoc is not being written before the process exits. The suspected issue is that Rustdoc spawns asynchronous writes here:
Lines 62 to 68 in f41927f
| rayon::spawn(move || { | |
| fs::write(&path, contents).unwrap_or_else(|e| { | |
| sender.send(format!("\"{}\": {}", path.display(), e)).unwrap_or_else(|_| { | |
| panic!("failed to send error on \"{}\"", path.display()) | |
| }) | |
| }); | |
| }); |
However, Rustdoc never checks that the writes are completed. We should add a mechanism that prevents the process from exiting before these write tasks are completed.
One possible solution:
- Add a field
outstanding_writes: Arc<AtomicUsize>toDocFS. - Increment
outstanding_writesat the start ofDocFS::write, and decrement at the end of the spawned Rayon task. - Add a method
DocFS::wait_for_outstanding_writes(&self)that spin-loops untiloutstanding_writesis zero. (Alternatively: use a condition variable, and havewritenotify the condvar whenoutstanding_writesis decremented.) - Either call
wait_for_outstanding_writesexplicitly in the end of the Rustdoc process, or add it as aDropimplementation toDocFS.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.