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

Document for debugging a test case #303

Open
scw00 opened this issue Feb 24, 2023 · 0 comments
Open

Document for debugging a test case #303

scw00 opened this issue Feb 24, 2023 · 0 comments

Comments

@scw00
Copy link

scw00 commented Feb 24, 2023

Hi, is there any more document that explain how to use LOOM_LOG to debug my own app.

use loom::sync::atomic::AtomicUsize;
use loom::sync::atomic::Ordering::{Acquire, Relaxed, Release, SeqCst};
use loom::sync::Arc;
use loom::thread;

#[test]
fn buggy_concurrent_inc() {
    loom::model(|| {
        let v1 = Arc::new(AtomicUsize::new(0));
        let v2 = v1.clone();

        thread::spawn(move || {
            v1.store(1, SeqCst);
        });

        loom::assert_eq
        //assert_eq!(0, v2.load(SeqCst));
    });
}

---- tests::buggy_concurrent_inc::buggy_concurrent_inc stdout ----
 INFO loom::model:
 INFO loom::model:  ================== Iteration 1 ==================
 INFO loom::model:
TRACE iter{1}: loom::rt::atomic: Atomic::new state=Ref<loom::rt::atomic::State>(0)
TRACE iter{1}: loom::rt::arc: Arc::new state=Ref<loom::rt::arc::State>(1) location=src/tests/buggy_concurrent_inc.rs:9:18
TRACE iter{1}: loom::rt::object: Object::branch_action obj=Ref<loom::rt::arc::State>(1) action=RefInc
TRACE iter{1}:thread{id=0}: loom::rt: branch switch=false
TRACE iter{1}:thread{id=0}: loom::rt::arc: Arc::ref_inc state=Ref<loom::rt::arc::State>(1) ref_cnt=2 location=src/tests/buggy_concurrent_inc.rs:10:21
TRACE iter{1}:thread{id=0}: loom::rt::notify: Notify::new state=Ref<loom::rt::notify::State>(2) seq_cst=true spurious=false
TRACE iter{1}:thread{id=0}: loom::rt: spawn thread=Id(1)
TRACE iter{1}:thread{id=0}: loom::rt::object: Object::branch_action obj=Ref<loom::rt::arc::State>(1) action=RefDec
 INFO iter{1}:thread{id=1}: loom::rt::execution: ~~~~~~~~ THREAD 1 ~~~~~~~~
TRACE iter{1}:thread{id=1}: loom::rt: branch switch=true
TRACE iter{1}:thread{id=1}: loom::rt::object: Object::branch_action obj=Ref<loom::rt::atomic::State>(0) action=Store
TRACE iter{1}:thread{id=1}: loom::rt: branch switch=false
TRACE iter{1}:thread{id=1}: loom::rt: synchronize
TRACE iter{1}:thread{id=1}: loom::rt::atomic: Atomic::store state=Ref<loom::rt::atomic::State>(0) ordering=SeqCst
TRACE iter{1}:thread{id=1}: loom::rt::object: Object::branch_action obj=Ref<loom::rt::arc::State>(1) action=RefDec
TRACE iter{1}:thread{id=1}: loom::rt: branch switch=false
TRACE iter{1}:thread{id=1}: loom::rt::arc: Arc::ref_dec state=Ref<loom::rt::arc::State>(1) ref_cnt=1 location=/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ptr/mod.rs:487:1
TRACE iter{1}:thread{id=1}: loom::rt::object: Object::branch_action obj=Ref<loom::rt::notify::State>(2) action=Opaque
TRACE iter{1}:thread{id=1}: loom::rt: branch switch=false
TRACE iter{1}:thread{id=1}: loom::rt: thread_done: drop locals thread=Id(1)
 INFO iter{1}:thread{id=0}: loom::rt::execution: ~~~~~~~~ THREAD 0 ~~~~~~~~
TRACE iter{1}:thread{id=0}: loom::rt: thread_done: terminate thread=Id(1) switch=true
TRACE iter{1}:thread{id=0}: loom::rt::arc: Arc::ref_dec state=Ref<loom::rt::arc::State>(1) ref_cnt=0 location=/rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ptr/mod.rs:487:1
TRACE iter{1}:thread{id=0}: loom::rt: thread_done: drop locals thread=Id(0)
thread 'tests::buggy_concurrent_inc::buggy_concurrent_inc' panicked at 'Reached unexpected exploration state. Is the model fully deterministic?', /Users/chenwei.scw/.cargo/registry/src/github.com-1ecc6299db9ec823/loom-0.5.6/src/rt/path.rs:279:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
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

1 participant