Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FsEventWatcher crashes when dealing with empty path #645

Open
kkolyan opened this issue Oct 13, 2024 · 0 comments
Open

FsEventWatcher crashes when dealing with empty path #645

kkolyan opened this issue Oct 13, 2024 · 0 comments
Assignees

Comments

@kkolyan
Copy link

kkolyan commented Oct 13, 2024

System details

  • OS/Platform name and version: Macos Ventura 13.4.1 (22F82), M1
  • Rust version (if building from source): rustc --version: rustc 1.81.0 (eeb90cda1 2024-09-04)
  • Notify version (or commit hash if building from git): 6.1.1

What you did (as detailed as you can)

  1. create empty cargo bin project (I created it in /Users/kkolyan/dev/rust/notify_crash directory, if that matters)
  2. add following to Cargo.toml dependencies section:
notify: 6.1.1
  1. set following code to main.rs
main.rs:
```rs
use std::{path::PathBuf, sync::atomic::{AtomicBool, Ordering}};

use notify::{EventKind, FsEventWatcher, Watcher};

fn main() {
    let need_refresh_flag = AtomicBool::new(false);
    let mut watcher: FsEventWatcher = notify::recommended_watcher(move |event: notify::Result<notify::Event>| {
        if let Ok(event) = event {
            if let EventKind::Modify(_) | EventKind::Create(_) | EventKind::Remove(_) =
                event.kind
            {
                need_refresh_flag.store(true, Ordering::Relaxed);
            }
        }
    }).unwrap();
    let path: PathBuf = Default::default();
    let _ = watcher.unwatch(&path);
    println!("It's ok");
}
  1. cargo run

What you expected

Program normally returns

What happened

It crashes with segmentation fault

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

No branches or pull requests

2 participants