From f73a43fd0a22fe9284fa224bc9e9af914cc306ce Mon Sep 17 00:00:00 2001 From: Marenz Date: Thu, 7 Apr 2016 15:17:42 +0200 Subject: [PATCH] fix Issue 15895 - Make rt_trapExceptions apply to fibers as well --- src/core/thread.d | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/core/thread.d b/src/core/thread.d index 75864fb99c..32e9342df5 100644 --- a/src/core/thread.d +++ b/src/core/thread.d @@ -3514,6 +3514,8 @@ shared static this() private { + extern extern (C) __gshared bool rt_trapExceptions; + extern (C) void fiber_entryPoint() { Fiber obj = Fiber.getThis(); @@ -3524,13 +3526,21 @@ private obj.m_ctxt.tstack = obj.m_ctxt.bstack; obj.m_state = Fiber.State.EXEC; - try + + if (rt_trapExceptions) { - obj.run(); + try + { + obj.run(); + } + catch( Throwable t ) + { + obj.m_unhandled = t; + } } - catch( Throwable t ) + else { - obj.m_unhandled = t; + obj.run(); } static if( __traits( compiles, ucontext_t ) )