From b9a7d24e8be129538ca6eafc310815bfdd1b9a72 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 23 May 2009 15:51:00 -0500 Subject: [PATCH] avoid too long messages back to top level if Yap_Error is called in a critical region. --- C/errors.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/C/errors.c b/C/errors.c index c36b0677a..32fa63c66 100644 --- a/C/errors.c +++ b/C/errors.c @@ -232,6 +232,7 @@ dump_stack(void) CELL *env_ptr = ENV; char tp[256]; yamop *ipc = CP; + int max_count = 200; #if DEBUG fprintf(stderr,"%% YAP regs: P=%p, CP=%p, ASP=%p, H=%p, TR=%p, HeapTop=%p\n",P,CP,ASP,H,TR,HeapTop); @@ -286,10 +287,18 @@ dump_stack(void) } else { fprintf(stderr,"%% %s\n", tp); } + if (!max_count--) { + fprintf(stderr,"%% .....\n"); + return; + } ipc = (yamop *)(env_ptr[E_CP]); env_ptr = (CELL *)(env_ptr[E_E]); } if (b_ptr) { + if (!max_count--) { + fprintf(stderr,"%% .....\n"); + return; + } if (b_ptr->cp_ap && /* tabling */ b_ptr->cp_ap->opc != Yap_opcode(_or_else) && b_ptr->cp_ap->opc != Yap_opcode(_or_last) && @@ -1764,6 +1773,17 @@ Yap_Error(yap_error_number type, Term where, char *format,...) ActiveSignals = 0; CreepFlag = CalculateStackGap(); Yap_PrologMode &= ~InErrorMode; + LOCK(SignalLock); + /* we might be in the middle of a critical region */ + if (!Yap_InterruptsDisabled) { + UncaughtThrow = TRUE; + UNLOCK(SignalLock); +#if PUSH_REGS + restore_absmi_regs(&Yap_standard_regs); +#endif + siglongjmp(Yap_RestartEnv,1); + } + UNLOCK(SignalLock); if (type == PURE_ABORT) Yap_JumpToEnv(MkAtomTerm(AtomDAbort)); else