From 1daaab43ac5b5dc9c8c220efc6c443250f4637e4 Mon Sep 17 00:00:00 2001 From: Eric Frias Date: Fri, 12 Sep 2014 14:28:56 -0400 Subject: [PATCH] Add assert to catch any time we yield during a catch{} block --- src/thread/thread_d.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/thread/thread_d.hpp b/src/thread/thread_d.hpp index 9af2762..05e4fbb 100644 --- a/src/thread/thread_d.hpp +++ b/src/thread/thread_d.hpp @@ -302,7 +302,20 @@ namespace fc { * have it wait for something to do. */ bool start_next_fiber( bool reschedule = false ) { + /* If this assert fires, it means you are executing an operation that is causing + * the current task to yield, but there is a ASSERT_TASK_NOT_PREEMPTED() in effect + * (somewhere up the stack) */ assert(non_preemptable_scope_count == 0); + + /* If this assert fires, it means you are causing the current task to yield while + * in the middle of handling an exception. The boost::context library's behavior + * is not well-defined in this case, and this has the potential to corrupt the + * exception stack, often resulting in a crash very soon after this */ + /* NB: At least on Win64, this only catches a yield while in the body of + * a catch block; it fails to catch a yield while unwinding the stack, which + * is probably just as likely to cause crashes */ + assert(std::current_exception() == std::exception_ptr()); + check_for_timeouts(); if( !current ) current = new fc::context( &fc::thread::current() );