-
Notifications
You must be signed in to change notification settings - Fork 111
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
provide better debugging facilities for nondeterministic tests #184
Open
bdonlan
wants to merge
4
commits into
tokio-rs:master
Choose a base branch
from
bdonlan:tracing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bdonlan
force-pushed
the
tracing
branch
4 times, most recently
from
October 23, 2020 22:04
03baf09
to
3484ad0
Compare
this is extremely cool! |
This change adds a new tracing facility that helps track down the source of nondeterministic execution. It records, for each branch point, the original (user) source code position leading to this branch, the operation being performed, and the reference that is involved in the branch. If this does not match on a later execution, we dump the mismatched operation, as well as a trace of recent operations, let the current execution run to completion, then panic. A typical trace looks a bit like this: ``` ===== NONDETERMINISTIC EXECUTION DETECTED ===== Previous execution: 13: [tests/nondet.rs:55:28] loom::thread::JoinHandle<()>::join on Thread::2 Current execution: 13: [tests/nondet.rs:55:28] loom::thread::JoinHandle<()>::join on Thread::3 Recent events: 0: [tests/nondet.rs:17:26] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 1: [tests/nondet.rs:18:19] loom::sync::arc::Arc<loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>>::clone on State::1 2: [tests/nondet.rs:35:9] loom::thread::yield_now ...: THREAD SWITCH on Thread::1 3: [tests/nondet.rs:21:30] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 ...: THREAD SWITCH on Thread::0 ...: loom::sync::mutex::MutexGuard<nondet::nondeterministic_execution_detected::State>::drop on Mutex::0 4: [tests/nondet.rs:17:26] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 5: [tests/nondet.rs:18:19] loom::sync::arc::Arc<loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>>::clone on State::1 6: [tests/nondet.rs:35:9] loom::thread::yield_now ...: THREAD SWITCH on Thread::2 7: [tests/nondet.rs:21:30] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 ...: THREAD SWITCH on Thread::0 ...: loom::sync::mutex::MutexGuard<nondet::nondeterministic_execution_detected::State>::drop on Mutex::0 8: [tests/nondet.rs:17:26] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 9: [tests/nondet.rs:18:19] loom::sync::arc::Arc<loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>>::clone on State::1 10: [tests/nondet.rs:35:9] loom::thread::yield_now ...: THREAD SWITCH on Thread::3 11: [tests/nondet.rs:21:30] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 ...: THREAD SWITCH on Thread::0 ...: loom::sync::mutex::MutexGuard<nondet::nondeterministic_execution_detected::State>::drop on Mutex::0 12: [tests/nondet.rs:45:30] loom::sync::mutex::Mutex<nondet::nondeterministic_execution_detected::State>::lock on Mutex::0 ...: loom::sync::mutex::MutexGuard<nondet::nondeterministic_execution_detected::State>::drop on Mutex::0 thread 'nondeterministic_execution_detected' panicked at 'Aborting due to non-deterministic execution', src/rt/execution.rs:262:13 stack backtrace: 0: std::panicking::begin_panic at /local/home/bdonlan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:497 1: loom::rt::execution::Execution::check_consistency at ./src/rt/execution.rs:262 2: loom::model::Builder::check at ./src/model.rs:208 3: loom::model::model at ./src/model.rs:230 4: nondet::nondeterministic_execution_detected at ./tests/nondet.rs:38 5: nondet::nondeterministic_execution_detected::{{closure}} at ./tests/nondet.rs:9 6: core::ops::function::FnOnce::call_once at /local/home/bdonlan/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227 7: core::ops::function::FnOnce::call_once at /rustc/18bf6b4f01a6feaf7259ba7cdae58031af1b7b39/library/core/src/ops/function.rs:227 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. test nondeterministic_execution_detected ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ```
This is needed for the Eq trait on `std::panic::Location`.
Panicing in drops can result in panic-in-panic events that make debugging harder than necessary. Make an attempt to catch panics coming from e.g. the execution being unavailable and just set a flag to cause the test to fail later instead.
wow this looks cool : ) random thought along this line: a "non-determinism checker" option that just executes each iteration twice with the same seed and reports if the traces diverge |
👋 hi @bdonlan, sorry this went so long without a review --- are you still interested in working on this? i'd love to give this branch a review if you're able to update it with the latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds a new tracing facility that helps track down the source of
nondeterministic execution. It records, for each branch point, the original
(user) source code position leading to this branch, the operation being
performed, and the reference that is involved in the branch. If this does not
match on a later execution, we dump the mismatched operation, as well as a
trace of recent operations, let the current execution run to completion, then
panic.
A typical trace looks a bit like this: