1 /* ---------------------------------------------------------------------------
3 * (c) The GHC Team, 1998-2006
5 * Asynchronous exceptions
7 * --------------------------------------------------------------------------*/
9 #include "PosixSource.h"
12 #include "sm/Storage.h"
15 #include "RaiseAsync.h"
20 #include "Profiling.h"
21 #include "eventlog/EventLog.h"
22 #if defined(mingw32_HOST_OS)
23 #include "win32/IOManager.h"
26 static void raiseAsync (Capability *cap,
28 StgClosure *exception,
29 rtsBool stop_at_atomically,
30 StgUpdateFrame *stop_here);
32 static void removeFromQueues(Capability *cap, StgTSO *tso);
34 static void blockedThrowTo (Capability *cap, StgTSO *source, StgTSO *target);
36 static void performBlockedException (Capability *cap,
37 StgTSO *source, StgTSO *target);
39 /* -----------------------------------------------------------------------------
42 This version of throwTo is safe to use if and only if one of the
47 - all the other threads in the system are stopped (eg. during GC).
49 - we surely own the target TSO (eg. we just took it from the
50 run queue of the current capability, or we are running it).
52 It doesn't cater for blocking the source thread until the exception
54 -------------------------------------------------------------------------- */
57 throwToSingleThreaded(Capability *cap, StgTSO *tso, StgClosure *exception)
59 throwToSingleThreaded_(cap, tso, exception, rtsFalse);
63 throwToSingleThreaded_(Capability *cap, StgTSO *tso, StgClosure *exception,
64 rtsBool stop_at_atomically)
66 // Thread already dead?
67 if (tso->what_next == ThreadComplete || tso->what_next == ThreadKilled) {
71 // Remove it from any blocking queues
72 removeFromQueues(cap,tso);
74 raiseAsync(cap, tso, exception, stop_at_atomically, NULL);
78 suspendComputation(Capability *cap, StgTSO *tso, StgUpdateFrame *stop_here)
80 // Thread already dead?
81 if (tso->what_next == ThreadComplete || tso->what_next == ThreadKilled) {
85 // Remove it from any blocking queues
86 removeFromQueues(cap,tso);
88 raiseAsync(cap, tso, NULL, rtsFalse, stop_here);
91 /* -----------------------------------------------------------------------------
94 This function may be used to throw an exception from one thread to
95 another, during the course of normal execution. This is a tricky
96 task: the target thread might be running on another CPU, or it
97 may be blocked and could be woken up at any point by another CPU.
98 We have some delicate synchronisation to do.
100 There is a completely safe fallback scheme: it is always possible
101 to just block the source TSO on the target TSO's blocked_exceptions
102 queue. This queue is locked using lockTSO()/unlockTSO(). It is
103 checked at regular intervals: before and after running a thread
104 (schedule() and threadPaused() respectively), and just before GC
105 (scheduleDoGC()). Activating a thread on this queue should be done
106 using maybePerformBlockedException(): this is done in the context
107 of the target thread, so the exception can be raised eagerly.
109 This fallback scheme works even if the target thread is complete or
110 killed: scheduleDoGC() will discover the blocked thread before the
113 Blocking the source thread on the target thread's blocked_exception
114 queue is also employed when the target thread is currently blocking
115 exceptions (ie. inside Control.Exception.block).
117 We could use the safe fallback scheme exclusively, but that
118 wouldn't be ideal: most calls to throwTo would block immediately,
119 possibly until the next GC, which might require the deadlock
120 detection mechanism to kick in. So we try to provide promptness
123 We can promptly deliver the exception if the target thread is:
125 - runnable, on the same Capability as the source thread (because
126 we own the run queue and therefore the target thread).
128 - blocked, and we can obtain exclusive access to it. Obtaining
129 exclusive access to the thread depends on how it is blocked.
131 We must also be careful to not trip over threadStackOverflow(),
132 which might be moving the TSO to enlarge its stack.
133 lockTSO()/unlockTSO() are used here too.
137 THROWTO_SUCCESS exception was raised, ok to continue
139 THROWTO_BLOCKED exception was not raised; block the source
140 thread then call throwToReleaseTarget() when
141 the source thread is properly tidied away.
143 -------------------------------------------------------------------------- */
146 throwTo (Capability *cap, // the Capability we hold
147 StgTSO *source, // the TSO sending the exception
148 StgTSO *target, // the TSO receiving the exception
149 StgClosure *exception, // the exception closure
150 /*[out]*/ void **out USED_IF_THREADS)
154 // follow ThreadRelocated links in the target first
155 while (target->what_next == ThreadRelocated) {
156 target = target->_link;
157 // No, it might be a WHITEHOLE:
158 // ASSERT(get_itbl(target)->type == TSO);
161 debugTrace(DEBUG_sched, "throwTo: from thread %lu to thread %lu",
162 (unsigned long)source->id, (unsigned long)target->id);
165 if (traceClass(DEBUG_sched)) {
166 debugTraceBegin("throwTo: target");
167 printThreadStatus(target);
174 debugTrace(DEBUG_sched, "throwTo: retrying...");
177 // Thread already dead?
178 if (target->what_next == ThreadComplete
179 || target->what_next == ThreadKilled) {
180 return THROWTO_SUCCESS;
183 status = target->why_blocked;
187 /* if status==NotBlocked, and target->cap == cap, then
188 we own this TSO and can raise the exception.
190 How do we establish this condition? Very carefully.
193 P = (status == NotBlocked)
194 Q = (tso->cap == cap)
196 Now, if P & Q are true, then the TSO is locked and owned by
197 this capability. No other OS thread can steal it.
199 If P==0 and Q==1: the TSO is blocked, but attached to this
200 capabilty, and it can be stolen by another capability.
202 If P==1 and Q==0: the TSO is runnable on another
203 capability. At any time, the TSO may change from runnable
204 to blocked and vice versa, while it remains owned by
207 Suppose we test like this:
213 this is defeated by another capability stealing a blocked
214 TSO from us to wake it up (Schedule.c:unblockOne()). The
215 other thread is doing
220 assuming arbitrary reordering, we could see this
230 so we need a memory barrier:
237 this avoids the problematic case. There are other cases
238 to consider, but this is the tricky one.
240 Note that we must be sure that unblockOne() does the
241 writes in the correct order: Q before P. The memory
242 barrier ensures that if we have seen the write to P, we
243 have also seen the write to Q.
246 Capability *target_cap;
249 target_cap = target->cap;
250 if (target_cap == cap && (target->flags & TSO_BLOCKEX) == 0) {
251 // It's on our run queue and not blocking exceptions
252 raiseAsync(cap, target, exception, rtsFalse, NULL);
253 return THROWTO_SUCCESS;
255 // Otherwise, just block on the blocked_exceptions queue
256 // of the target thread. The queue will get looked at
257 // soon enough: it is checked before and after running a
258 // thread, and during GC.
261 // Avoid race with threadStackOverflow, which may have
262 // just moved this TSO.
263 if (target->what_next == ThreadRelocated) {
265 target = target->_link;
268 // check again for ThreadComplete and ThreadKilled. This
269 // cooperates with scheduleHandleThreadFinished to ensure
270 // that we never miss any threads that are throwing an
271 // exception to a thread in the process of terminating.
272 if (target->what_next == ThreadComplete
273 || target->what_next == ThreadKilled) {
275 return THROWTO_SUCCESS;
277 blockedThrowTo(cap,source,target);
279 return THROWTO_BLOCKED;
286 To establish ownership of this TSO, we need to acquire a
287 lock on the MVar that it is blocked on.
290 StgInfoTable *info USED_IF_THREADS;
292 mvar = (StgMVar *)target->block_info.closure;
294 // ASSUMPTION: tso->block_info must always point to a
295 // closure. In the threaded RTS it does.
296 switch (get_itbl(mvar)->type) {
304 info = lockClosure((StgClosure *)mvar);
306 if (target->what_next == ThreadRelocated) {
307 target = target->_link;
308 unlockClosure((StgClosure *)mvar,info);
311 // we have the MVar, let's check whether the thread
312 // is still blocked on the same MVar.
313 if (target->why_blocked != BlockedOnMVar
314 || (StgMVar *)target->block_info.closure != mvar) {
315 unlockClosure((StgClosure *)mvar, info);
319 if ((target->flags & TSO_BLOCKEX) &&
320 ((target->flags & TSO_INTERRUPTIBLE) == 0)) {
321 lockClosure((StgClosure *)target);
322 blockedThrowTo(cap,source,target);
323 unlockClosure((StgClosure *)mvar, info);
325 return THROWTO_BLOCKED; // caller releases TSO
327 removeThreadFromMVarQueue(cap, mvar, target);
328 raiseAsync(cap, target, exception, rtsFalse, NULL);
329 unblockOne(cap, target);
330 unlockClosure((StgClosure *)mvar, info);
331 return THROWTO_SUCCESS;
335 case BlockedOnBlackHole:
337 ACQUIRE_LOCK(&sched_mutex);
338 // double checking the status after the memory barrier:
339 if (target->why_blocked != BlockedOnBlackHole) {
340 RELEASE_LOCK(&sched_mutex);
344 if (target->flags & TSO_BLOCKEX) {
346 blockedThrowTo(cap,source,target);
347 RELEASE_LOCK(&sched_mutex);
349 return THROWTO_BLOCKED; // caller releases TSO
351 removeThreadFromQueue(cap, &blackhole_queue, target);
352 raiseAsync(cap, target, exception, rtsFalse, NULL);
353 unblockOne(cap, target);
354 RELEASE_LOCK(&sched_mutex);
355 return THROWTO_SUCCESS;
359 case BlockedOnException:
365 To obtain exclusive access to a BlockedOnException thread,
366 we must call lockClosure() on the TSO on which it is blocked.
367 Since the TSO might change underneath our feet, after we
368 call lockClosure() we must check that
370 (a) the closure we locked is actually a TSO
371 (b) the original thread is still BlockedOnException,
372 (c) the original thread is still blocked on the TSO we locked
373 and (d) the target thread has not been relocated.
375 We synchronise with threadStackOverflow() (which relocates
376 threads) using lockClosure()/unlockClosure().
378 target2 = target->block_info.tso;
380 info = lockClosure((StgClosure *)target2);
381 if (info != &stg_TSO_info) {
382 unlockClosure((StgClosure *)target2, info);
385 if (target->what_next == ThreadRelocated) {
386 target = target->_link;
390 if (target2->what_next == ThreadRelocated) {
391 target->block_info.tso = target2->_link;
395 if (target->why_blocked != BlockedOnException
396 || target->block_info.tso != target2) {
402 Now we have exclusive rights to the target TSO...
404 If it is blocking exceptions, add the source TSO to its
405 blocked_exceptions queue. Otherwise, raise the exception.
407 if ((target->flags & TSO_BLOCKEX) &&
408 ((target->flags & TSO_INTERRUPTIBLE) == 0)) {
410 blockedThrowTo(cap,source,target);
413 return THROWTO_BLOCKED;
415 removeThreadFromQueue(cap, &target2->blocked_exceptions, target);
416 raiseAsync(cap, target, exception, rtsFalse, NULL);
417 unblockOne(cap, target);
419 return THROWTO_SUCCESS;
425 // Unblocking BlockedOnSTM threads requires the TSO to be
426 // locked; see STM.c:unpark_tso().
427 if (target->why_blocked != BlockedOnSTM) {
431 if ((target->flags & TSO_BLOCKEX) &&
432 ((target->flags & TSO_INTERRUPTIBLE) == 0)) {
433 blockedThrowTo(cap,source,target);
435 return THROWTO_BLOCKED;
437 raiseAsync(cap, target, exception, rtsFalse, NULL);
438 unblockOne(cap, target);
440 return THROWTO_SUCCESS;
444 case BlockedOnCCall_NoUnblockExc:
445 // I don't think it's possible to acquire ownership of a
446 // BlockedOnCCall thread. We just assume that the target
447 // thread is blocking exceptions, and block on its
448 // blocked_exception queue.
450 if (target->why_blocked != BlockedOnCCall &&
451 target->why_blocked != BlockedOnCCall_NoUnblockExc) {
455 blockedThrowTo(cap,source,target);
457 return THROWTO_BLOCKED;
459 #ifndef THREADEDED_RTS
463 #if defined(mingw32_HOST_OS)
464 case BlockedOnDoProc:
466 if ((target->flags & TSO_BLOCKEX) &&
467 ((target->flags & TSO_INTERRUPTIBLE) == 0)) {
468 blockedThrowTo(cap,source,target);
469 return THROWTO_BLOCKED;
471 removeFromQueues(cap,target);
472 raiseAsync(cap, target, exception, rtsFalse, NULL);
473 return THROWTO_SUCCESS;
478 barf("throwTo: unrecognised why_blocked value");
483 // Block a TSO on another TSO's blocked_exceptions queue.
484 // Precondition: we hold an exclusive lock on the target TSO (this is
485 // complex to achieve as there's no single lock on a TSO; see
488 blockedThrowTo (Capability *cap, StgTSO *source, StgTSO *target)
490 debugTrace(DEBUG_sched, "throwTo: blocking on thread %lu", (unsigned long)target->id);
491 setTSOLink(cap, source, target->blocked_exceptions);
492 target->blocked_exceptions = source;
493 dirty_TSO(cap,target); // we modified the blocked_exceptions queue
495 source->block_info.tso = target;
496 write_barrier(); // throwTo_exception *must* be visible if BlockedOnException is.
497 source->why_blocked = BlockedOnException;
503 throwToReleaseTarget (void *tso)
505 unlockTSO((StgTSO *)tso);
509 /* -----------------------------------------------------------------------------
510 Waking up threads blocked in throwTo
512 There are two ways to do this: maybePerformBlockedException() will
513 perform the throwTo() for the thread at the head of the queue
514 immediately, and leave the other threads on the queue.
515 maybePerformBlockedException() also checks the TSO_BLOCKEX flag
516 before raising an exception.
518 awakenBlockedExceptionQueue() will wake up all the threads in the
519 queue, but not perform any throwTo() immediately. This might be
520 more appropriate when the target thread is the one actually running
523 Returns: non-zero if an exception was raised, zero otherwise.
524 -------------------------------------------------------------------------- */
527 maybePerformBlockedException (Capability *cap, StgTSO *tso)
531 if (tso->what_next == ThreadComplete || tso->what_next == ThreadFinished) {
532 if (tso->blocked_exceptions != END_TSO_QUEUE) {
533 awakenBlockedExceptionQueue(cap,tso);
540 if (tso->blocked_exceptions != END_TSO_QUEUE &&
541 (tso->flags & TSO_BLOCKEX) != 0) {
542 debugTrace(DEBUG_sched, "throwTo: thread %lu has blocked exceptions but is inside block", (unsigned long)tso->id);
545 if (tso->blocked_exceptions != END_TSO_QUEUE
546 && ((tso->flags & TSO_BLOCKEX) == 0
547 || ((tso->flags & TSO_INTERRUPTIBLE) && interruptible(tso)))) {
549 // Lock the TSO, this gives us exclusive access to the queue
552 // Check the queue again; it might have changed before we
554 if (tso->blocked_exceptions == END_TSO_QUEUE) {
559 // We unblock just the first thread on the queue, and perform
560 // its throw immediately.
561 source = tso->blocked_exceptions;
562 performBlockedException(cap, source, tso);
563 tso->blocked_exceptions = unblockOne_(cap, source,
564 rtsFalse/*no migrate*/);
571 // awakenBlockedExceptionQueue(): Just wake up the whole queue of
572 // blocked exceptions and let them try again.
575 awakenBlockedExceptionQueue (Capability *cap, StgTSO *tso)
578 awakenBlockedQueue(cap, tso->blocked_exceptions);
579 tso->blocked_exceptions = END_TSO_QUEUE;
584 performBlockedException (Capability *cap, StgTSO *source, StgTSO *target)
586 StgClosure *exception;
588 ASSERT(source->why_blocked == BlockedOnException);
589 ASSERT(source->block_info.tso->id == target->id);
590 ASSERT(source->sp[0] == (StgWord)&stg_block_throwto_info);
591 ASSERT(((StgTSO *)source->sp[1])->id == target->id);
592 // check ids not pointers, because the thread might be relocated
594 exception = (StgClosure *)source->sp[2];
595 throwToSingleThreaded(cap, target, exception);
599 /* -----------------------------------------------------------------------------
600 Remove a thread from blocking queues.
602 This is for use when we raise an exception in another thread, which
605 Precondition: we have exclusive access to the TSO, via the same set
606 of conditions as throwToSingleThreaded() (c.f.).
607 -------------------------------------------------------------------------- */
610 removeFromQueues(Capability *cap, StgTSO *tso)
612 switch (tso->why_blocked) {
618 // Be careful: nothing to do here! We tell the scheduler that the
619 // thread is runnable and we leave it to the stack-walking code to
620 // abort the transaction while unwinding the stack. We should
621 // perhaps have a debugging test to make sure that this really
622 // happens and that the 'zombie' transaction does not get
627 removeThreadFromMVarQueue(cap, (StgMVar *)tso->block_info.closure, tso);
630 case BlockedOnBlackHole:
631 removeThreadFromQueue(cap, &blackhole_queue, tso);
634 case BlockedOnException:
636 StgTSO *target = tso->block_info.tso;
638 // NO: when called by threadPaused(), we probably have this
639 // TSO already locked (WHITEHOLEd) because we just placed
640 // ourselves on its queue.
641 // ASSERT(get_itbl(target)->type == TSO);
643 while (target->what_next == ThreadRelocated) {
644 target = target->_link;
647 removeThreadFromQueue(cap, &target->blocked_exceptions, tso);
651 #if !defined(THREADED_RTS)
654 #if defined(mingw32_HOST_OS)
655 case BlockedOnDoProc:
657 removeThreadFromDeQueue(cap, &blocked_queue_hd, &blocked_queue_tl, tso);
658 #if defined(mingw32_HOST_OS)
659 /* (Cooperatively) signal that the worker thread should abort
662 abandonWorkRequest(tso->block_info.async_result->reqID);
667 removeThreadFromQueue(cap, &sleeping_queue, tso);
672 barf("removeFromQueues: %d", tso->why_blocked);
676 unblockOne(cap, tso);
679 /* -----------------------------------------------------------------------------
682 * The following function implements the magic for raising an
683 * asynchronous exception in an existing thread.
685 * We first remove the thread from any queue on which it might be
686 * blocked. The possible blockages are MVARs and BLACKHOLE_BQs.
688 * We strip the stack down to the innermost CATCH_FRAME, building
689 * thunks in the heap for all the active computations, so they can
690 * be restarted if necessary. When we reach a CATCH_FRAME, we build
691 * an application of the handler to the exception, and push it on
692 * the top of the stack.
694 * How exactly do we save all the active computations? We create an
695 * AP_STACK for every UpdateFrame on the stack. Entering one of these
696 * AP_STACKs pushes everything from the corresponding update frame
697 * upwards onto the stack. (Actually, it pushes everything up to the
698 * next update frame plus a pointer to the next AP_STACK object.
699 * Entering the next AP_STACK object pushes more onto the stack until we
700 * reach the last AP_STACK object - at which point the stack should look
701 * exactly as it did when we killed the TSO and we can continue
702 * execution by entering the closure on top of the stack.
704 * We can also kill a thread entirely - this happens if either (a) the
705 * exception passed to raiseAsync is NULL, or (b) there's no
706 * CATCH_FRAME on the stack. In either case, we strip the entire
707 * stack and replace the thread with a zombie.
709 * ToDo: in THREADED_RTS mode, this function is only safe if either
710 * (a) we hold all the Capabilities (eg. in GC, or if there is only
711 * one Capability), or (b) we own the Capability that the TSO is
712 * currently blocked on or on the run queue of.
714 * -------------------------------------------------------------------------- */
717 raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
718 rtsBool stop_at_atomically, StgUpdateFrame *stop_here)
720 StgRetInfoTable *info;
725 debugTrace(DEBUG_sched,
726 "raising exception in thread %ld.", (long)tso->id);
728 #if defined(PROFILING)
730 * Debugging tool: on raising an exception, show where we are.
731 * See also Exception.cmm:raisezh_fast.
732 * This wasn't done for asynchronous exceptions originally; see #1450
734 if (RtsFlags.ProfFlags.showCCSOnException)
736 fprintCCS_stderr(tso->prof.CCCS);
740 // mark it dirty; we're about to change its stack.
745 // ASSUMES: the thread is not already complete or dead. Upper
746 // layers should deal with that.
747 ASSERT(tso->what_next != ThreadComplete && tso->what_next != ThreadKilled);
749 if (stop_here != NULL) {
750 updatee = stop_here->updatee;
755 // The stack freezing code assumes there's a closure pointer on
756 // the top of the stack, so we have to arrange that this is the case...
758 if (sp[0] == (W_)&stg_enter_info) {
762 sp[0] = (W_)&stg_dummy_ret_closure;
766 while (stop_here == NULL || frame < (StgPtr)stop_here) {
768 // 1. Let the top of the stack be the "current closure"
770 // 2. Walk up the stack until we find either an UPDATE_FRAME or a
773 // 3. If it's an UPDATE_FRAME, then make an AP_STACK containing the
774 // current closure applied to the chunk of stack up to (but not
775 // including) the update frame. This closure becomes the "current
776 // closure". Go back to step 2.
778 // 4. If it's a CATCH_FRAME, then leave the exception handler on
779 // top of the stack applied to the exception.
781 // 5. If it's a STOP_FRAME, then kill the thread.
783 // NB: if we pass an ATOMICALLY_FRAME then abort the associated
786 info = get_ret_itbl((StgClosure *)frame);
788 switch (info->i.type) {
795 // First build an AP_STACK consisting of the stack chunk above the
796 // current update frame, with the top word on the stack as the
799 words = frame - sp - 1;
800 ap = (StgAP_STACK *)allocateLocal(cap,AP_STACK_sizeW(words));
803 ap->fun = (StgClosure *)sp[0];
805 for(i=0; i < (nat)words; ++i) {
806 ap->payload[i] = (StgClosure *)*sp++;
809 SET_HDR(ap,&stg_AP_STACK_info,
810 ((StgClosure *)frame)->header.prof.ccs /* ToDo */);
811 TICK_ALLOC_UP_THK(words+1,0);
813 //IF_DEBUG(scheduler,
814 // debugBelch("sched: Updating ");
815 // printPtr((P_)((StgUpdateFrame *)frame)->updatee);
816 // debugBelch(" with ");
817 // printObj((StgClosure *)ap);
820 if (((StgUpdateFrame *)frame)->updatee == updatee) {
821 // If this update frame points to the same closure as
822 // the update frame further down the stack
823 // (stop_here), then don't perform the update. We
824 // want to keep the blackhole in this case, so we can
825 // detect and report the loop (#2783).
826 ap = (StgAP_STACK*)updatee;
828 // Perform the update
829 // TODO: this may waste some work, if the thunk has
830 // already been updated by another thread.
831 UPD_IND(((StgUpdateFrame *)frame)->updatee, (StgClosure *)ap);
834 sp += sizeofW(StgUpdateFrame) - 1;
835 sp[0] = (W_)ap; // push onto stack
837 continue; //no need to bump frame
842 // We've stripped the entire stack, the thread is now dead.
843 tso->what_next = ThreadKilled;
844 tso->sp = frame + sizeofW(StgStopFrame);
849 // If we find a CATCH_FRAME, and we've got an exception to raise,
850 // then build the THUNK raise(exception), and leave it on
851 // top of the CATCH_FRAME ready to enter.
855 StgCatchFrame *cf = (StgCatchFrame *)frame;
859 if (exception == NULL) break;
861 // we've got an exception to raise, so let's pass it to the
862 // handler in this frame.
864 raise = (StgThunk *)allocateLocal(cap,sizeofW(StgThunk)+1);
865 TICK_ALLOC_SE_THK(1,0);
866 SET_HDR(raise,&stg_raise_info,cf->header.prof.ccs);
867 raise->payload[0] = exception;
869 // throw away the stack from Sp up to the CATCH_FRAME.
873 /* Ensure that async excpetions are blocked now, so we don't get
874 * a surprise exception before we get around to executing the
877 tso->flags |= TSO_BLOCKEX | TSO_INTERRUPTIBLE;
879 /* Put the newly-built THUNK on top of the stack, ready to execute
880 * when the thread restarts.
883 sp[-1] = (W_)&stg_enter_info;
885 tso->what_next = ThreadRunGHC;
886 IF_DEBUG(sanity, checkTSO(tso));
890 case ATOMICALLY_FRAME:
891 if (stop_at_atomically) {
892 ASSERT(stmGetEnclosingTRec(tso->trec) == NO_TREC);
893 stmCondemnTransaction(cap, tso -> trec);
895 tso->what_next = ThreadRunGHC;
898 // Not stop_at_atomically... fall through and abort the
901 case CATCH_STM_FRAME:
902 case CATCH_RETRY_FRAME:
903 // IF we find an ATOMICALLY_FRAME then we abort the
904 // current transaction and propagate the exception. In
905 // this case (unlike ordinary exceptions) we do not care
906 // whether the transaction is valid or not because its
907 // possible validity cannot have caused the exception
908 // and will not be visible after the abort.
911 StgTRecHeader *trec = tso -> trec;
912 StgTRecHeader *outer = stmGetEnclosingTRec(trec);
913 debugTrace(DEBUG_stm,
914 "found atomically block delivering async exception");
915 stmAbortTransaction(cap, trec);
916 stmFreeAbortedTRec(cap, trec);
925 // move on to the next stack frame
926 frame += stack_frame_sizeW((StgClosure *)frame);
929 // if we got here, then we stopped at stop_here
930 ASSERT(stop_here != NULL);