# We ignore the LD_PRELOAD lines from the expected output because they contain the build path ! ignore .*LD_PRELOAD.* # This test raises a deadlock, thus the return code of 3 ! expect return 3 $ $VALGRIND_NO_TRACE_CHILDREN ${bindir:=.}/../../bin/simgrid-mc --cfg=model-check/setenv:LD_PRELOAD=${libdir:=.}/libsthread.so ${bindir:=.}/pthread-mutex-simpledeadlock > All threads are started. > [0.000000] [mc_dfs/INFO] Start a DFS exploration. Reduction is: dpor. > The thread 0 is terminating. > The thread 1 is terminating. > User's main is terminating. > [0.000000] [mc_global/INFO] ************************** > [0.000000] [mc_global/INFO] *** DEADLOCK DETECTED *** > [0.000000] [mc_global/INFO] ************************** > [0.000000] [ker_engine/INFO] 3 actors are still running, waiting for something. > [0.000000] [ker_engine/INFO] Legend of the following listing: "Actor (@): " > [0.000000] [ker_engine/INFO] Actor 1 (main thread@Lilibeth) simcall ActorJoin(pid:2) > [0.000000] [ker_engine/INFO] Actor 2 (thread 1@Lilibeth) simcall MUTEX_WAIT(mutex_id:1 owner:3) > [0.000000] [ker_engine/INFO] Actor 3 (thread 2@Lilibeth) simcall MUTEX_WAIT(mutex_id:0 owner:2) > [0.000000] [mc_global/INFO] Counter-example execution trace: > [0.000000] [mc_global/INFO] Actor 2 in simcall MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) > [0.000000] [mc_global/INFO] Actor 2 in simcall MUTEX_WAIT(mutex: 0, owner: 2) > [0.000000] [mc_global/INFO] Actor 3 in simcall MUTEX_ASYNC_LOCK(mutex: 1, owner: 3) > [0.000000] [mc_global/INFO] Actor 2 in simcall MUTEX_ASYNC_LOCK(mutex: 1, owner: 3) > [0.000000] [mc_global/INFO] Actor 3 in simcall MUTEX_WAIT(mutex: 1, owner: 3) > [0.000000] [mc_global/INFO] Actor 3 in simcall MUTEX_ASYNC_LOCK(mutex: 0, owner: 2) > [0.000000] [mc_Session/INFO] You can debug the problem (and see the whole details) by rerunning out of simgrid-mc with --cfg=model-check/replay:'2;2;3;2;3;3' > [0.000000] [mc_dfs/INFO] DFS exploration ended. 21 unique states visited; 3 backtracks (11 transition replays, 35 states visited overall) # The return code of a replay is not modified ! expect return 0 ! output display ! setenv LD_PRELOAD=${libdir:=.}/libsthread.so $ $VALGRIND_NO_TRACE_CHILDREN ${bindir:=.}/pthread-mutex-simpledeadlock --cfg=model-check/replay:'2;2;3;2;3;3' # The output contains build paths, and cannot be tested with tesh, unfortunately # Here, it will produce the following output (if you don't build out of the tree, you'll get another output): # $ LD_PRELOAD=${libdir:=.}/libsthread.so ${bindir:=.}/pthread-mutex-simpledeadlock --cfg=model-check/replay:'2;2;3;2;3;3' # sthread is intercepting the execution of ./pthread-mutex-simpledeadlock # [0.000000] [xbt_cfg/INFO] Configuration change: Set 'model-check/replay' to '2;2;3;2;3;3' # [0.000000] [mc_record/INFO] path=2;2;3;2;3;3 # All threads are started. # [0.000000] [mc_record/INFO] *********************************************************************************** # [0.000000] [mc_record/INFO] * Path chunk #1 '2/0' Actor thread 1(pid:2): MUTEX_ASYNC_LOCK(mutex_id:0 owner:none) # [0.000000] [mc_record/INFO] *********************************************************************************** # Backtrace (displayed in actor thread 1): # -> #0 simgrid::s4u::Mutex::lock() at ../../src/s4u/s4u_Mutex.cpp:26 # -> #1 sthread_mutex_lock at ../../src/sthread/sthread_impl.cpp:188 # -> #2 pthread_mutex_lock at ../../src/sthread/sthread.c:141 # -> #3 thread_fun1 at ../../examples/sthread/pthread-mutex-simpledeadlock.c:21 # # [0.000000] [mc_record/INFO] *********************************************************************************** # [0.000000] [mc_record/INFO] * Path chunk #2 '2/0' Actor thread 1(pid:2): MUTEX_WAIT(mutex_id:0 owner:2) # [0.000000] [mc_record/INFO] *********************************************************************************** # Backtrace (displayed in actor thread 1): # -> #0 simgrid::s4u::Mutex::lock() at ../../src/s4u/s4u_Mutex.cpp:29 # -> #1 sthread_mutex_lock at ../../src/sthread/sthread_impl.cpp:188 # -> #2 pthread_mutex_lock at ../../src/sthread/sthread.c:141 # -> #3 thread_fun1 at ../../examples/sthread/pthread-mutex-simpledeadlock.c:21 # # [0.000000] [mc_record/INFO] *********************************************************************************** # [0.000000] [mc_record/INFO] * Path chunk #3 '3/0' Actor thread 2(pid:3): MUTEX_ASYNC_LOCK(mutex_id:1 owner:none) # [0.000000] [mc_record/INFO] *********************************************************************************** # Backtrace (displayed in actor thread 2): # -> #0 simgrid::s4u::Mutex::lock() at ../../src/s4u/s4u_Mutex.cpp:26 # -> #1 sthread_mutex_lock at ../../src/sthread/sthread_impl.cpp:188 # -> #2 pthread_mutex_lock at ../../src/sthread/sthread.c:141 # -> #3 thread_fun2 at ../../examples/sthread/pthread-mutex-simpledeadlock.c:31 # # [0.000000] [mc_record/INFO] *********************************************************************************** # [0.000000] [mc_record/INFO] * Path chunk #4 '2/0' Actor thread 1(pid:2): MUTEX_ASYNC_LOCK(mutex_id:1 owner:3) # [0.000000] [mc_record/INFO] *********************************************************************************** # Backtrace (displayed in actor thread 1): # -> #0 simgrid::s4u::Mutex::lock() at ../../src/s4u/s4u_Mutex.cpp:26 # -> #1 sthread_mutex_lock at ../../src/sthread/sthread_impl.cpp:188 # -> #2 pthread_mutex_lock at ../../src/sthread/sthread.c:141 # -> #3 thread_fun1 at ../../examples/sthread/pthread-mutex-simpledeadlock.c:22 # # [0.000000] [mc_record/INFO] *********************************************************************************** # [0.000000] [mc_record/INFO] * Path chunk #5 '3/0' Actor thread 2(pid:3): MUTEX_WAIT(mutex_id:1 owner:3) # [0.000000] [mc_record/INFO] *********************************************************************************** # Backtrace (displayed in actor thread 2): # -> #0 simgrid::s4u::Mutex::lock() at ../../src/s4u/s4u_Mutex.cpp:29 # -> #1 sthread_mutex_lock at ../../src/sthread/sthread_impl.cpp:188 # -> #2 pthread_mutex_lock at ../../src/sthread/sthread.c:141 # -> #3 thread_fun2 at ../../examples/sthread/pthread-mutex-simpledeadlock.c:31 # # [0.000000] [mc_record/INFO] *********************************************************************************** # [0.000000] [mc_record/INFO] * Path chunk #6 '3/0' Actor thread 2(pid:3): MUTEX_ASYNC_LOCK(mutex_id:0 owner:2) # [0.000000] [mc_record/INFO] *********************************************************************************** # Backtrace (displayed in actor thread 2): # -> #0 simgrid::s4u::Mutex::lock() at ../../src/s4u/s4u_Mutex.cpp:26 # -> #1 sthread_mutex_lock at ../../src/sthread/sthread_impl.cpp:188 # -> #2 pthread_mutex_lock at ../../src/sthread/sthread.c:141 # -> #3 thread_fun2 at ../../examples/sthread/pthread-mutex-simpledeadlock.c:32 # # [0.000000] [mc_record/INFO] The replay of the trace is complete. DEADLOCK detected. # [0.000000] [ker_engine/INFO] 3 actors are still running, waiting for something. # [0.000000] [ker_engine/INFO] Legend of the following listing: "Actor (@): " # [0.000000] [ker_engine/INFO] Actor 1 (main thread@Lilibeth) simcall ActorJoin(pid:2) # [0.000000] [ker_engine/INFO] Actor 2 (thread 1@Lilibeth) simcall MUTEX_WAIT(mutex_id:1 owner:3) # [0.000000] [ker_engine/INFO] Actor 3 (thread 2@Lilibeth) simcall MUTEX_WAIT(mutex_id:0 owner:2) # [0.000000] [sthread/INFO] All threads exited. Terminating the simulation. # [0.000000] ../../src/kernel/EngineImpl.cpp:265: [ker_engine/WARNING] Process called exit when leaving - Skipping cleanups # [0.000000] ../../src/kernel/EngineImpl.cpp:265: [ker_engine/WARNING] Process called exit when leaving - Skipping cleanups #