diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-08-07 18:57:56 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-08-07 18:57:56 +0800 |
commit | 69fd09133591e6a1d5733f4321df4a81a71cb856 (patch) | |
tree | f4c55222fab42f74cb49800fc2b26093737c46c7 | |
parent | 7980ff17aa557d5546d920271f47c68ab498714b (diff) | |
download | mrust-69fd09133591e6a1d5733f4321df4a81a71cb856.tar.gz |
Standalone MIRI - Tweaked panic handling
-rw-r--r-- | tools/standalone_miri/miri.cpp | 16 | ||||
-rw-r--r-- | tools/standalone_miri/miri.hpp | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp index 957a69f1..09855329 100644 --- a/tools/standalone_miri/miri.cpp +++ b/tools/standalone_miri/miri.cpp @@ -1534,7 +1534,8 @@ bool InterpreterThread::step_one(Value& out_thread_result) LOG_TODO("Terminator::Incomplete hit"); TU_ARM(bb.terminator, Diverge, _te) LOG_DEBUG("DIVERGE (continue panic)"); - assert(m_thread.panic_active); + assert(m_thread.panic_count > 0); + m_thread.panic_active = true; return this->pop_stack(out_thread_result); TU_ARM(bb.terminator, Panic, _te) LOG_TODO("Terminator::Panic"); @@ -1705,7 +1706,7 @@ bool InterpreterThread::step_one(Value& out_thread_result) // If a panic is in progress (in thread state), take the panic block instead if( m_thread.panic_active ) { - //m_thread.panic_active = false; + m_thread.panic_active = false; LOG_DEBUG("Panic into " << cur_frame.fcn->my_path); cur_frame.bb_idx = te.panic_block; } @@ -1770,7 +1771,7 @@ bool InterpreterThread::pop_stack(Value& out_thread_result) // If a panic is in progress (in thread state), take the panic block instead if( m_thread.panic_active ) { - //m_thread.panic_active = false; + m_thread.panic_active = false; LOG_DEBUG("Panic into " << cur_frame.fcn->my_path); cur_frame.bb_idx = te.panic_block; } @@ -1994,6 +1995,7 @@ bool InterpreterThread::call_extern(Value& rv, const ::std::string& link_name, c LOG_DEBUG("_Unwind_RaiseException(" << args.at(0) << ")"); // Save the first argument in TLS, then return a status that indicates unwinding should commence. m_thread.panic_active = true; + m_thread.panic_count += 1; m_thread.panic_value = ::std::move(args.at(0)); } #ifdef _WIN32 @@ -2811,8 +2813,12 @@ bool InterpreterThread::call_intrinsic(Value& rv, const RcString& name, const :: { LOG_TODO("Panic caught in `try` - " << m_thread.panic_value); } - out_rv = Value::new_u32(0); - return true; + else + { + LOG_ASSERT(m_thread.panic_count == 0, "Panic count non-zero, but previous function returned non-panic"); + out_rv = Value::new_u32(0); + return true; + } })); // TODO: Catch the panic out of this. diff --git a/tools/standalone_miri/miri.hpp b/tools/standalone_miri/miri.hpp index 9c3da72b..0b0f8f39 100644 --- a/tools/standalone_miri/miri.hpp +++ b/tools/standalone_miri/miri.hpp @@ -15,11 +15,13 @@ struct ThreadState unsigned call_stack_depth; ::std::vector< ::std::pair<uint64_t, RelocationPtr> > tls_values; + unsigned panic_count; bool panic_active; Value panic_value; ThreadState(): call_stack_depth(0) + ,panic_count(0) ,panic_active(false) { } |