notify-rs / notify

🔭 Cross-platform filesystem notification library for Rust.
https://docs.rs/notify
2.77k stars 222 forks source link

Bug: Crashes on Windows when the watched directory no longer exists in release mode #624

Open sxyazi opened 4 months ago

sxyazi commented 4 months ago

System details

What you did (as detailed as you can)

  1. Watch directory a
  2. Delete directory a
  3. Build and run in release mode (important)
  4. The app crashes

What you expected

Not crashes

What happened

I can reproduce it with the following code through cargo run --release on Windows:

fn main() {
  let p = Path::new("C:\\Users\\ika\\Desktop\\abc");
  std::fs::create_dir(p).unwrap();

  let mut watcher = ::notify::RecommendedWatcher::new(|_| {}, Default::default()).unwrap();
  watcher.watch(p, ::notify::RecursiveMode::NonRecursive).unwrap();

  // Try to comment on this line you'll see "Exited successfully" printed normally
  std::fs::remove_dir_all(p).unwrap();

  std::thread::sleep(Duration::from_secs(5));
  println!("Exited successfully");
}

Error message:

error: process didn't exit successfully: `target\release\test.exe` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)
sxyazi commented 4 months ago

Oh I found a related PR here https://github.com/notify-rs/notify/pull/602

But it seems not included in the latest release, is it possible to create a patch version for it?