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

test_waker_threaded fails or hangs in Rust 1.70 #19

Open
danielparks opened this issue Jul 8, 2023 · 5 comments · May be fixed by #20
Open

test_waker_threaded fails or hangs in Rust 1.70 #19

danielparks opened this issue Jul 8, 2023 · 5 comments · May be fixed by #20

Comments

@danielparks
Copy link
Contributor

Running test_waker_threaded in Rust 1.70 on macOS almost always either fails or hangs indefinitely.

---- tests::test_waker_threaded stdout ----
thread 'tests::test_waker_threaded' panicked at 'called `Result::unwrap_err()` on an `Ok` value: ()', src/lib.rs:1003:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@danielparks
Copy link
Contributor Author

As a side note, why is their a rust-toolchain file in git? I always end up deleting it, since for whatever reason it doesn’t work on my machine even though I have 1.64 installed.

@danielparks
Copy link
Contributor Author

I found and fixed a few race conditions, but I still have an intermittent hang. Threaded code is a pain.

danielparks added a commit to danielparks/popol that referenced this issue Jul 8, 2023
This fixes a few race conditions in `test_waker_threaded()` and adds a
timeout to ensure that it doesn’t hang forever if something goes wrong.

Fixes: cloudhead#19 — test_waker_threaded fails or hangs in Rust 1.70
danielparks added a commit to danielparks/popol that referenced this issue Jul 8, 2023
This fixes a few race conditions in `test_waker_threaded()` and adds a
timeout to ensure that it doesn’t hang forever if something goes wrong.

Fixes: cloudhead#19 — test_waker_threaded fails or hangs in Rust 1.70
danielparks added a commit to danielparks/popol that referenced this issue Jul 8, 2023
This fixes a few race conditions in `test_waker_threaded()` and adds a
timeout to ensure that it doesn’t hang forever if something goes wrong.

Some notes:

  * It is always possible to have messages on the channel after the
    thread has finished, since the thread could write a message and
    finish between the call to `poll()` and the start of the next loop.
  * `reset()` could swallow the last wake.
  * It is possible to get either timeouts or events from `poll()` after
    the thread finishes. I’m not sure how it gets more events, but when
    I only checked for `is_finished()` when getting a timeout, it
    sometimes hung forever.

Fixes: cloudhead#19 — test_waker_threaded fails or hangs in Rust 1.70
@danielparks danielparks linked a pull request Jul 8, 2023 that will close this issue
@cloudhead
Copy link
Owner

Hmm my prefered approach might be to just run that test on linux.

@danielparks
Copy link
Contributor Author

I just confirmed that it happens on Linux sometimes, too. I suspect that the version of Rust is also irrelevant — it’s just a matter of making the race condition more or less likely, rather than avoiding it entirely.

I also just ran into a race condition in test_threaded() on Linux (though, again, I think it’s just a case of being more or less likely in certain circumstances).

Threaded code is a giant pain.

@danielparks
Copy link
Contributor Author

Filed #22 for the test_threaded bug.

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 a pull request may close this issue.

2 participants