Improve error handling routine, trying to make it more robust.
Improve hole handling in stack expansion Clause interrpeter was supposed to prune _trust_me Wrong messages for acos and atanh git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1249 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
bdff56d3b0
commit
9807a22069
@ -797,7 +797,7 @@ p_asin(Term t E_ARGS)
|
||||
out = asin(dbl);
|
||||
#if HAVE_ISNAN
|
||||
if (isnan(out)) {
|
||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t, "acos(%f)", dbl);
|
||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t, "asin(%f)", dbl);
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ p_atanh(Term t E_ARGS)
|
||||
out = atanh(dbl);
|
||||
#if HAVE_ISNAN
|
||||
if (isnan(out)) {
|
||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t, "acosh(%f)", dbl);
|
||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, t, "atanh(%f)", dbl);
|
||||
P = (yamop *)FAILCODE;
|
||||
RERROR();
|
||||
}
|
||||
|
@ -5118,4 +5118,3 @@ Yap_InitBackDB(void)
|
||||
Yap_InitCPredBack("$current_immediate_key", 2, 4, init_current_key, cont_current_key,
|
||||
SyncPredFlag|HiddenPredFlag);
|
||||
}
|
||||
|
||||
|
26
C/errors.c
26
C/errors.c
@ -267,6 +267,12 @@ dump_stack(void)
|
||||
char tp[256];
|
||||
yamop *ipc = CP;
|
||||
|
||||
#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);
|
||||
fprintf(stderr,"%% YAP mode: %x\n",Yap_PrologMode);
|
||||
if (Yap_ErrorMessage)
|
||||
fprintf(stderr,"%% YAP_ErrorMessage: %s\n",Yap_ErrorMessage);
|
||||
#endif
|
||||
if (H > ASP || H > LCL0) {
|
||||
fprintf(stderr,"%% YAP ERROR: Global Collided against Local (%p--%p)\n",H,ASP);
|
||||
} else if (HeapTop > (ADDR)Yap_GlobalBase) {
|
||||
@ -293,7 +299,10 @@ dump_stack(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
fprintf (stderr,"Goal Stack Dump (* is backtrack point)\n");
|
||||
detect_bug_location(P, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
|
||||
fprintf (stderr,"Running code at %s\n",(char *)H);
|
||||
detect_bug_location(CP, FIND_PRED_FROM_ANYWHERE, (char *)H, 256);
|
||||
fprintf (stderr,"Continuation is at %s\n",(char *)H);
|
||||
while (b_ptr != NULL) {
|
||||
while (env_ptr && env_ptr <= (CELL *)b_ptr) {
|
||||
detect_bug_location(ipc, FIND_PRED_FROM_ENV, tp, 256);
|
||||
@ -362,7 +371,9 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
char *tp = tmpbuf;
|
||||
int psize = YAP_BUF_SIZE;
|
||||
|
||||
|
||||
#if DEBUG
|
||||
fprintf(stderr,"***** Processing Error %d (%x,%x) ***\n", type, ActiveSignals,Yap_PrologMode);
|
||||
#endif
|
||||
if (type == INTERRUPT_ERROR) {
|
||||
fprintf(stderr,"%% YAP exiting: cannot handle signal %d\n",
|
||||
(int)IntOfTerm(where));
|
||||
@ -421,8 +432,6 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
Yap_PrologMode &= ~AbortMode;
|
||||
Yap_PrologMode |= InErrorMode;
|
||||
} else {
|
||||
if (type != SYNTAX_ERROR)
|
||||
where = Yap_CopyTerm(Deref(where));
|
||||
if (IsVarTerm(where)) {
|
||||
/* we must be careful someone gave us a copy to a local variable */
|
||||
Term t = MkVarTerm();
|
||||
@ -432,7 +441,9 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
/* Exit Abort Mode, if we were there */
|
||||
Yap_PrologMode &= ~AbortMode;
|
||||
Yap_PrologMode |= InErrorMode;
|
||||
where = Yap_CopyTerm(where);
|
||||
if (!(where = Yap_CopyTerm(where))) {
|
||||
where = TermNil;
|
||||
}
|
||||
}
|
||||
va_start (ap, format);
|
||||
/* now build the error string */
|
||||
@ -1653,6 +1664,9 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
nt[1] = MkPairTerm(MkAtomTerm(Yap_LookupAtom(tmpbuf)), Yap_all_calls());
|
||||
}
|
||||
if (serious) {
|
||||
/* disable active signals at this point */
|
||||
ActiveSignals = 0;
|
||||
CreepFlag = CalculateStackGap();
|
||||
if (type == PURE_ABORT)
|
||||
Yap_JumpToEnv(MkAtomTerm(Yap_LookupAtom("$abort")));
|
||||
else
|
||||
@ -1660,6 +1674,6 @@ Yap_Error(yap_error_number type, Term where, char *format,...)
|
||||
P = (yamop *)FAILCODE;
|
||||
}
|
||||
Yap_PrologMode &= ~InErrorMode;
|
||||
return(P);
|
||||
return P;
|
||||
}
|
||||
|
||||
|
10
C/grow.c
10
C/grow.c
@ -228,10 +228,10 @@ MoveLocalAndTrail(void)
|
||||
static void
|
||||
MoveGlobal(void)
|
||||
{
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
* absmi.asm
|
||||
*/
|
||||
/*
|
||||
* cpcellsd(To,From,NOfCells) - copy the cells downwards - in
|
||||
* absmi.asm
|
||||
*/
|
||||
#if HAVE_MEMMOVE
|
||||
cpcellsd((CELL *)Yap_GlobalBase, (CELL *)OldGlobalBase, OldH - (CELL *)OldGlobalBase);
|
||||
#else
|
||||
@ -1067,7 +1067,7 @@ execute_growstack(long size0, int from_trail, int in_parser, tr_fr_ptr *old_trp,
|
||||
return FALSE;
|
||||
}
|
||||
YAPEnterCriticalSection();
|
||||
GDiff = DelayDiff = size;
|
||||
GDiff = DelayDiff = size-size0;
|
||||
} else {
|
||||
YAPEnterCriticalSection();
|
||||
if (Yap_GlobalBase != old_Yap_GlobalBase) {
|
||||
|
@ -3400,7 +3400,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
*--ASP = (CELL)current_env;
|
||||
if (!Yap_growheap(FALSE, MinHeapGap, NULL)) {
|
||||
Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
current_env = (CELL *)*ASP;
|
||||
ASP++;
|
||||
@ -3566,7 +3566,7 @@ call_gc(UInt gc_lim, Int predarity, CELL *current_env, yamop *nextop)
|
||||
if (gc_margin < gc_lim)
|
||||
gc_margin = gc_lim;
|
||||
GcCalls++;
|
||||
if (gc_on) {
|
||||
if (gc_on && !(Yap_PrologMode & InErrorMode)) {
|
||||
effectiveness = do_gc(predarity, current_env, nextop);
|
||||
if (effectiveness > 90) {
|
||||
while (gc_margin < H-H0)
|
||||
|
14
C/index.c
14
C/index.c
@ -11,8 +11,12 @@
|
||||
* File: index.c *
|
||||
* comments: Indexing a Prolog predicate *
|
||||
* *
|
||||
* Last rev: $Date: 2005-02-21 16:50:00 $,$Author: vsc $ *
|
||||
* Last rev: $Date: 2005-02-24 21:46:39 $,$Author: vsc $ *
|
||||
* $Log: not supported by cvs2svn $
|
||||
* Revision 1.115 2005/02/21 16:50:00 vsc
|
||||
* amd64 fixes
|
||||
* library fixes
|
||||
*
|
||||
* Revision 1.114 2005/01/28 23:14:36 vsc
|
||||
* move to Yap-4.5.7
|
||||
* Fix clause size
|
||||
@ -7607,6 +7611,14 @@ Yap_FollowIndexingCode(PredEntry *ap, yamop *ipc, Term Terms[3], yamop *ap_pc, y
|
||||
case _trust_me2:
|
||||
case _trust_me3:
|
||||
case _trust_me4:
|
||||
#ifdef YAPOR
|
||||
CUT_prune_to(B->cp_b);
|
||||
#else
|
||||
B = B->cp_b;
|
||||
#endif /* YAPOR */
|
||||
#ifdef TABLING
|
||||
abolish_incomplete_subgoals(B);
|
||||
#endif /* TABLING */
|
||||
b0 = B;
|
||||
ipc = NEXTOP(ipc,ld);
|
||||
break;
|
||||
|
@ -296,7 +296,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
||||
}
|
||||
|
||||
static Term
|
||||
CopyTerm(Term inp) {
|
||||
CopyTerm(Term inp, UInt arity) {
|
||||
Term t = Deref(inp);
|
||||
|
||||
if (IsVarTerm(t)) {
|
||||
@ -310,21 +310,21 @@ CopyTerm(Term inp) {
|
||||
Hi = H+1;
|
||||
H += 2;
|
||||
if ((res = copy_complex_term(Hi-2, Hi-1, Hi, Hi)) < 0) {
|
||||
ARG3 = t;
|
||||
XREGS[arity+1] = t;
|
||||
H = Hi-1;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = Deref(ARG3);
|
||||
t = Deref(XREGS[arity+1]);
|
||||
goto restart_attached;
|
||||
} else { /* handle overflow */
|
||||
if (!Yap_ExpandPreAllocCodeSpace(0,NULL)) {
|
||||
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = Deref(ARG3);
|
||||
t = Deref(XREGS[arity+1]);
|
||||
goto restart_attached;
|
||||
}
|
||||
}
|
||||
@ -348,20 +348,20 @@ CopyTerm(Term inp) {
|
||||
int res;
|
||||
if ((res = copy_complex_term(ap-1, ap+1, Hi, Hi)) < 0) {
|
||||
H = Hi;
|
||||
ARG3 = t;
|
||||
XREGS[arity+1] = t;
|
||||
if (res == -1) { /* handle overflow */
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = Deref(ARG3);
|
||||
t = Deref(XREGS[arity+1]);
|
||||
goto restart_list;
|
||||
} else { /* handle overflow */
|
||||
if (!Yap_ExpandPreAllocCodeSpace(0,NULL)) {
|
||||
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = Deref(ARG3);
|
||||
t = Deref(XREGS[arity+1]);
|
||||
goto restart_list;
|
||||
}
|
||||
}
|
||||
@ -385,20 +385,20 @@ CopyTerm(Term inp) {
|
||||
|
||||
if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), HB0+1, HB0)) < 0) {
|
||||
H = HB0;
|
||||
ARG3 = t;
|
||||
XREGS[arity+1] = t;
|
||||
if (res == -1) {
|
||||
if (!Yap_gc(3, ENV, P)) {
|
||||
if (!Yap_gc(arity+1, ENV, P)) {
|
||||
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = Deref(ARG3);
|
||||
t = Deref(XREGS[arity+1]);
|
||||
goto restart_appl;
|
||||
} else { /* handle overflow */
|
||||
if (!Yap_ExpandPreAllocCodeSpace(0,NULL)) {
|
||||
Yap_Error(OUT_OF_AUXSPACE_ERROR, TermNil, Yap_ErrorMessage);
|
||||
return FALSE;
|
||||
}
|
||||
t = Deref(ARG3);
|
||||
t = Deref(XREGS[arity+1]);
|
||||
goto restart_appl;
|
||||
}
|
||||
}
|
||||
@ -409,13 +409,13 @@ CopyTerm(Term inp) {
|
||||
|
||||
Term
|
||||
Yap_CopyTerm(Term inp) {
|
||||
return CopyTerm(inp);
|
||||
return CopyTerm(inp, 0);
|
||||
}
|
||||
|
||||
static Int
|
||||
p_copy_term(void) /* copy term t to a new instance */
|
||||
{
|
||||
Term t = CopyTerm(ARG1);
|
||||
Term t = CopyTerm(ARG1, 2);
|
||||
if (t == 0L)
|
||||
return FALSE;
|
||||
/* be careful, there may be a stack shift here */
|
||||
@ -688,7 +688,6 @@ p_copy_term_no_delays(void) /* copy term t to a new instance */
|
||||
{
|
||||
Term t = CopyTermNoDelays(ARG1);
|
||||
if (t == 0L) {
|
||||
printf("Error\n");
|
||||
return FALSE;
|
||||
}
|
||||
/* be careful, there may be a stack shift here */
|
||||
|
Reference in New Issue
Block a user