diff --git a/C/exec.c b/C/exec.c index 70a6e11cd..4b6aa50ef 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1439,7 +1439,11 @@ static int is_cleanup_cp(choiceptr cp_b) #else pe = cp_b->cp_ap->u.p.p; #endif /* YAPOR */ - return (pe == PredSafeCallCleanup); + /* + it has to be a cleanup and it has to be a completed goal, + otherwise the throw will be caught anyway. + */ + return pe == PredSafeCallCleanup; } static Int diff --git a/H/trim_trail.h b/H/trim_trail.h index 779d25afb..afd2720de 100644 --- a/H/trim_trail.h +++ b/H/trim_trail.h @@ -33,7 +33,6 @@ Bind(pt, MkAtomTerm(AtomCut)); Yap_WakeUp(pt); } - pt1--; } else if ((*pt & (LogUpdMask|IndexMask)) == (LogUpdMask|IndexMask)) { LogUpdIndex *cl = ClauseFlagsToLogUpdIndex(pt); int erase; diff --git a/pl/control.yap b/pl/control.yap index 3f96d0cf1..d2708b234 100644 --- a/pl/control.yap +++ b/pl/control.yap @@ -67,9 +67,7 @@ setup_call_cleanup(Setup, Goal, Cleanup) :- setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :- yap_hacks:disable_interrupts, '$do_setup'(Setup), - catch('$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception), - Exception, - '$cleanup_exception'(Exception,Catcher,Cleanup)). + '$safe_call_cleanup'(Goal,Cleanup,Catcher,Exception). % this is simple, do nothing '$do_setup'(A:true) :- atom(A), !. @@ -96,9 +94,9 @@ setup_call_catcher_cleanup(Setup, Goal, Catcher, Cleanup) :- '$safe_call_cleanup'(Goal, Cleanup, Catcher, Exception) :- yap_hacks:current_choice_point(MyCP1), - '$freeze_goal'(Catcher, '$clean_call'(Exception, Cleanup)), - yap_hacks:trail_suspension_marker(Catcher), + '$freeze_goal'(Catcher, '$clean_call'(Active, Cleanup)), ( + yap_hacks:trail_suspension_marker(Catcher), yap_hacks:enable_interrupts, yap_hacks:current_choice_point(CP0), '$execute'(Goal),