Code Monkey home page Code Monkey logo

fsevent-rust's Introduction

fsevent-rust's People

Contributors

a1phyr avatar alexanderkjall avatar andelf avatar chills42 avatar erickt avatar jakerr avatar johntitor avatar kali avatar ldm0 avatar mtak- avatar octplane avatar passcod avatar shanegibbs avatar sheeldotme avatar simonchatts avatar waywardmonkeys avatar zacbrown avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fsevent-rust's Issues

Unable to decode StreamFlags: 3212032

I am not 100% sure what caused this panic, but potentially, it was a commit to a git repo that was being monitored for fs events. This is the backtrace.

thread '<unnamed>' panicked at 'Unable to decode StreamFlags: 3212032', ../src/libcore/option.rs:700
stack backtrace:
   1:        0x10896913e - std::sys::backtrace::tracing::imp::write::h29f5fdb9fc0a7395
   2:        0x10896ca2f - std::panicking::default_hook::_{{closure}}::h2cc84f0378700526
   3:        0x10896bd8b - std::panicking::default_hook::hbbe7fa36a995aca0
   4:        0x10896c397 - std::panicking::rust_panic_with_hook::h105c3d42fcd2fb5e
   5:        0x10896c254 - std::panicking::begin_panic::hbf62ea4a5ff3f9de
   6:        0x10896c162 - std::panicking::begin_panic_fmt::h20f5943904e5791d
   7:        0x10896c0c7 - rust_begin_unwind
   8:        0x108996c7d - core::panicking::panic_fmt::h19323e466869c656
   9:        0x108996ced - core::option::expect_failed::h5c893070d569702e
  10:        0x1088c7393 - _<core..option..Option<T>>::expect::h3fd640de5cdb8714
  11:        0x1088f9861 - notify::fsevent::callback::ha08d529e8690f9e3
  12:     0x7fff9bce2b0a - implementation_callback_rpc
  13:     0x7fff9bce06c9 - _Xcallback_rpc
  14:     0x7fff9bce079d - FSEventsD2F_server
  15:     0x7fff9bce5fd8 - FSEventsClientProcessMessageCallback
  16:     0x7fff9b34112b - __CFMachPortPerform
  17:     0x7fff9b341018 - __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
  18:     0x7fff9b340f88 - __CFRunLoopDoSource1
  19:     0x7fff9b3389ba - __CFRunLoopRun
  20:     0x7fff9b337ed7 - CFRunLoopRunSpecific
  21:     0x7fff9b3799b0 - CFRunLoopRun
  22:        0x1088fbe47 - notify::fsevent::FsEventWatcher::run::_{{closure}}::h7c9524f5a4947436
  23:        0x1088f859c - _<std..panic..AssertUnwindSafe<F> as core..ops..FnOnce<()>>::call_once::h826e04f275096133
  24:        0x1088fbb54 - std::panicking::try::_{{closure}}::_{{closure}}::hb09551845c8a0008
  25:        0x1088cbcbc - std::panicking::try::call::h47f6979155451676
  26:        0x10896d02a - __rust_maybe_catch_panic
  27:        0x1088fba6e - std::panicking::try::_{{closure}}::hc2071c10857d4c73
  28:        0x1088d09e5 - _<std..thread..local..LocalKey<T>>::with::h6c80b5d40b886fef
  29:        0x1088cbc0d - std::panicking::try::h9b03b8b74b847b38
  30:        0x1088cad50 - std::panic::catch_unwind::h14c9291bec764a56
  31:        0x1088fb7b2 - std::thread::Builder::spawn::_{{closure}}::heff91d698bfca38b
  32:        0x1088e9db0 - _<F as alloc..boxed..FnBox<A>>::call_box::h9a4ccf94f4cabe77
  33:        0x10896b405 - std::sys::thread::Thread::new::thread_start::h8f3bd45211e9f5ea
  34:     0x7fff9690399c - _pthread_body
  35:     0x7fff96903919 - _pthread_start

notify failing on MacOS due to new fsevent-sys update

On the bevy github page, our CI builds are failing due to a recent update within the fsevent-sys crate.
See CI failures here.

CI failed due to:

error[E0308]: mismatched types
   --> /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/notify-5.0.0-pre.7/src/fsevent.rs:361:17
    |
361 |                 callback,
    |                 ^^^^^^^^ expected `u32`, found enum `c_void`
    |
    = note: expected fn pointer `extern "C" fn(_, _, _, _, *const u32, *const u64)`
                  found fn item `extern "C" fn(_, _, _, _, *const c_void, *const c_void) {callback}`

Here is the related notify issue

Unsupported flags: 4293888

Experienced on macOS High Sierra, possibly as a result of a filesystem update in the latest OS release:

thread '<unnamed>' panicked at 'Unable to decode StreamFlags: 4293888', src/libcore/option.rs:File change notification: RawEvent { path: Some("/Users/mqudsi/Library/Messages/Attachments/b5/05/BA79380F-DDF7-43CD-9A6A-A878B7CCF20F"), op: Ok(CHMOD | CREATE), cookie: None }
819:4
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::option::expect_failed
   9: <core::option::Option<T>>::expect
  10: notify::fsevent::callback
  11: implementation_callback_rpc
  12: _Xcallback_rpc
  13: FSEventsD2F_server
  14: FSEventsClientProcessMessageCallback
  15: __CFMachPortPerform
  16: __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__
  17: __CFRunLoopDoSource1
  18: __CFRunLoopRun
  19: CFRunLoopRunSpecific
  20: CFRunLoopRun
  21: notify::fsevent::FsEventWatcher::run::{{closure}}

Similar to #5 except I'm running 0.2.16

Two of the tests appear to be susceptible to race conditions

Two of the tests appear to be susceptible to race conditions.

With the current head of master – the tree at 8b1698e – on macOS Catalina with Rust 1.41.0, after initial cloning of the fsevent-rust repository and first run of cargo test, two of the tests failed.

The tests that failed were observe_folder_async and observe_folder_sync. The test output from that initial invocation of cargo test was:

   Compiling libc v0.2.68
   Compiling getrandom v0.1.14
   Compiling cfg-if v0.1.10
   Compiling ppv-lite86 v0.2.6
   Compiling bitflags v1.2.1
   Compiling remove_dir_all v0.5.2
   Compiling fsevent-sys v3.0.0
   Compiling time v0.1.42
   Compiling fsevent v2.0.1 (/Users/erikn/src/github.com/octplane/fsevent-rust)
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand v0.7.3
   Compiling tempfile v3.1.0
    Finished test [unoptimized + debuginfo] target(s) in 10.76s
     Running target/debug/deps/fsevent-ce679260b5d6056f

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/fsevent-a3719c7d2dc1d40b

running 4 tests
test observe_folder_sync ... FAILED
test observe_folder_async ... FAILED
test validate_watch_single_file_sync ... ok
test validate_watch_single_file_async ... ok

failures:

---- observe_folder_sync stdout ----
thread 'observe_folder_sync' panicked at 'Some expected events did not occur before the test timedout:
		[("/private/var/folders/97/2k44164n2s9c3_c9zydgdz_80000gn/T/durj2526W/dest1", ITEM_CREATED | IS_DIR), ("/private/var/folders/97/2k44164n2s9c3_c9zydgdz_80000gn/T/durj2526W/dest2", ITEM_CREATED | IS_DIR)]', tests/fsevent.rs:45:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- observe_folder_async stdout ----
thread 'observe_folder_async' panicked at 'Some expected events did not occur before the test timedout:
		[("/private/var/folders/97/2k44164n2s9c3_c9zydgdz_80000gn/T/duru38162/dest1", ITEM_CREATED | IS_DIR)]', tests/fsevent.rs:45:5


failures:
    observe_folder_async
    observe_folder_sync

test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--test fsevent'

Notice that the failure output of one of the tests mentions "dest1" and "dest2", and the failure output of the other test mentions "dest1".

Looking at the tests, we have:

#[test]
fn observe_folder_sync() {
    internal_observe_folder(false);
}

and

#[test]
fn observe_folder_async() {
    internal_observe_folder(true);
}

Looking then at internal_observe_folder, we have:

fn internal_observe_folder(run_async: bool) {

Inside of which, first a bunch of directories are created

    let dir = tempfile::Builder::new().prefix("dur").tempdir().unwrap();
    // Resolve path so we don't have to worry about affect of symlinks on the test.
    let dst = resolve_path(dir.path().to_str().unwrap());

    let mut dst1 = dst.clone();
    dst1.push("dest1");

    let ddst1 = dst1.clone();
    fs::create_dir(dst1.as_path().to_str().unwrap()).unwrap();

    let mut dst2 = dst.clone();

    dst2.push("dest2");
    let ddst2 = dst2.clone();
    fs::create_dir(dst2.as_path().to_str().unwrap()).unwrap();

    let mut dst3 = dst.clone();

    dst3.push("dest3");
    let ddst3 = dst3.clone();
    fs::create_dir(dst3.as_path().to_str().unwrap()).unwrap();

Then a channel is created, and the directories are observed

    let (sender, receiver) = channel();

    let mut async_fsevent = fsevent::FsEvent::new(vec![]);
    let fsevent_ref_wrapper = if run_async {
        async_fsevent
            .append_path(dst1.as_path().to_str().unwrap())
            .unwrap();
        async_fsevent
            .append_path(dst2.as_path().to_str().unwrap())
            .unwrap();
        async_fsevent
            .append_path(dst3.as_path().to_str().unwrap())
            .unwrap();
        Some(async_fsevent.observe_async(sender).unwrap())
    } else {
        let _t = thread::spawn(move || {
            let mut fsevent = fsevent::FsEvent::new(vec![]);
            fsevent
                .append_path(dst1.as_path().to_str().unwrap())
                .unwrap();
            fsevent
                .append_path(dst2.as_path().to_str().unwrap())
                .unwrap();
            fsevent
                .append_path(dst3.as_path().to_str().unwrap())
                .unwrap();
            fsevent.observe(sender);
        });
        None
    };

Then, it proceeds to attempt to validate that it received the ITEM_CREATED events for the directories it was watching (and then after that there is the shutdown stuff for the async observer).

    validate_recv(
        receiver,
        vec![
            (
                ddst1.to_str().unwrap().to_string(),
                StreamFlags::ITEM_CREATED | StreamFlags::IS_DIR,
            ),
            (
                ddst2.to_str().unwrap().to_string(),
                StreamFlags::ITEM_CREATED | StreamFlags::IS_DIR,
            ),
            (
                ddst3.to_str().unwrap().to_string(),
                StreamFlags::ITEM_CREATED | StreamFlags::IS_DIR,
            ),
        ],
    );

    match fsevent_ref_wrapper {
        Some(r) => async_fsevent.shutdown_observe(r),
        None => {}
    }
}

But keep in mind that the directory creation was initiated prior to watching those paths.

Upon subsequently running the tests again a few times, both with and without doing a rebuild of the tests themselves in-between, all four tests passed.

But from the initial failure that I saw, and from the code I quoted above, this looks like a case of susceptibility to race conditions to me.

Also, the test case seems a little odd to me. Is there a particular reason for subscribing to events on all three of those the paths "dest1", "dest2" and "dest3" rather than subscribing to none of those and instead subscribing to the initial temporary directory that is created (dst) before creating dst1, dst2 and dst3 and then verifying that the creation of dst1, dst2 and dst3 is seen from the observer of dst? I am thinking that I might be missing something here.

error occurred when git commit

Used the example code to watch a git repo,
It works just fine until i do git commit in the watched repo.

> cargo run --verbose
       Fresh libc v0.2.2
       Fresh bitflags v0.3.3
       Fresh fsevent-sys v0.1.3
       Fresh fsevent v0.2.11
       Fresh dummy v0.1.0 (file:///Users/yangcheng/repos/dummy)
     Running `target/debug/dummy`
thread '<unnamed>' panicked at 'Unable to decode StreamFlags: 1115136', ../src/libcore/option.rs:333
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', ../src/libcore/result.rs:736
Process didn't exit successfully: `target/debug/dummy` (exit code: 101)

hardlink creation is not picked up

Hardlink creation is not noticed. Don't know if this is a bug in fsevent/fsevent-sys, or if it's just how the Apple File System Events API works, or if there is some other problem.

Regular file creation, and even deletion of hardlinks are noticed and reported though.

Steps to reproduce:

  1. On an APFS file system on macOS Catalina, create a directory that we will watch. As an example, let's do:

    mkdir -p ~/tmp/hello/world/
  2. Create a file somewhere outside of the watched directory structure.

    touch ~/tmp/hello/somefile
  3. Use the fsevent crate to watch the directory that we created in step 1 (~/tmp/hello/world/).

  4. Create a regular file in the watched directory.

    touch ~/tmp/hello/world/one
  5. Notice that the file creation is picked up as expected.

  6. Create a hardlink inside of the watched directory.

    cd ~/tmp/hello/world/ && ln ../somefile .
  7. The hardlink creation is not noticed by fsevent.

fsevent compilation error since https://github.com/octplane/fsevent-rust/commit/cc3489854e88bce6d7e6ddf274dc3711111fde69

Since fhttps://github.com/octplane/fsevent-rust/commit/cc3489854e88bce6d7e6ddf274dc3711111fde69 we have the following:

   --> /Users/gary/.cargo/registry/src/github.com-1ecc6299db9ec823/fsevent-0.4.0/src/lib.rs:171:17
    |
171 |         retain: cf::NULL,
    |                 ^^^^^^^^ expected enum `std::option::Option`, found *-ptr
    |
    = note: expected type `std::option::Option<extern "C" fn(*const std::ffi::c_void) -> *const std::ffi::c_void>`
               found type `*mut std::ffi::c_void`

error[E0308]: mismatched types
   --> /Users/gary/.cargo/registry/src/github.com-1ecc6299db9ec823/fsevent-0.4.0/src/lib.rs:172:27
    |
172 |         copy_description: cf::NULL,
    |                           ^^^^^^^^ expected enum `std::option::Option`, found *-ptr
    |
    = note: expected type `std::option::Option<extern "C" fn(*const std::ffi::c_void) -> *const *mut std::ffi::c_void>`
               found type `*mut std::ffi::c_void`

error[E0063]: missing field `release` in initializer of `fsevent::FSEventStreamContext`
   --> /Users/gary/.cargo/registry/src/github.com-1ecc6299db9ec823/fsevent-0.4.0/src/lib.rs:168:5
    |
168 |     fs::FSEventStreamContext {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ missing `release`

error[E0308]: mismatched types
   --> /Users/gary/.cargo/registry/src/github.com-1ecc6299db9ec823/fsevent-0.4.0/src/lib.rs:276:17
    |
276 |                 cb,
    |                 ^^ expected fn pointer, found *-ptr
    |
    = note: expected type `extern "C" fn(*mut std::ffi::c_void, *mut std::ffi::c_void, usize, *mut std::ffi::c_void, *const std::ffi::c_void, *const std::ffi::c_void)`
               found type `*mut _`

This is breaking most of our library - can you please advise?A

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.