fix some overflows recorded.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1141 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
0de365678a
commit
bb2cb9e9f8
@ -10,8 +10,11 @@
|
|||||||
* *
|
* *
|
||||||
* File: absmi.c *
|
* File: absmi.c *
|
||||||
* comments: Portable abstract machine interpreter *
|
* comments: Portable abstract machine interpreter *
|
||||||
* Last rev: $Date: 2004-09-17 19:34:49 $,$Author: vsc $ *
|
* Last rev: $Date: 2004-09-17 20:47:35 $,$Author: vsc $ *
|
||||||
* $Log: not supported by cvs2svn $
|
* $Log: not supported by cvs2svn $
|
||||||
|
* Revision 1.144 2004/09/17 19:34:49 vsc
|
||||||
|
* simplify frozen/2
|
||||||
|
*
|
||||||
* Revision 1.143 2004/08/16 21:02:04 vsc
|
* Revision 1.143 2004/08/16 21:02:04 vsc
|
||||||
* more fixes for !
|
* more fixes for !
|
||||||
*
|
*
|
||||||
@ -2454,7 +2457,7 @@ Yap_absmi(int inp)
|
|||||||
/* This is easier: I know there is an environment so I cannot do allocate */
|
/* This is easier: I know there is an environment so I cannot do allocate */
|
||||||
NoStackCommitY:
|
NoStackCommitY:
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
|
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||||
goto do_commit_b_y;
|
goto do_commit_b_y;
|
||||||
}
|
}
|
||||||
if (ActiveSignals != YAP_CREEP_SIGNAL) {
|
if (ActiveSignals != YAP_CREEP_SIGNAL) {
|
||||||
@ -2469,7 +2472,7 @@ Yap_absmi(int inp)
|
|||||||
/* Problem: have I got an environment or not? */
|
/* Problem: have I got an environment or not? */
|
||||||
NoStackCommitX:
|
NoStackCommitX:
|
||||||
/* find something to fool S */
|
/* find something to fool S */
|
||||||
if (ActiveSignals & YAP_CDOVF_SIGNAL) {
|
if (!ActiveSignals || ActiveSignals & YAP_CDOVF_SIGNAL) {
|
||||||
goto do_commit_b_x;
|
goto do_commit_b_x;
|
||||||
}
|
}
|
||||||
if (ActiveSignals != YAP_CREEP_SIGNAL) {
|
if (ActiveSignals != YAP_CREEP_SIGNAL) {
|
||||||
|
54
C/dbase.c
54
C/dbase.c
@ -3437,16 +3437,54 @@ p_recorded(void)
|
|||||||
if (!Yap_unify(ARG2, cl->ClSource->Entry)) {
|
if (!Yap_unify(ARG2, cl->ClSource->Entry)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else if (!Yap_unify(ARG2,GetDBTerm(cl->ClSource))) {
|
} else {
|
||||||
return FALSE;
|
Term TermDB;
|
||||||
|
while ((TermDB = GetDBTerm(cl->ClSource)) == (CELL)0) {
|
||||||
|
/* oops, we are in trouble, not enough stack space */
|
||||||
|
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
|
||||||
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||||
|
if (!Yap_growglobal(NULL)) {
|
||||||
|
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||||
|
if (!Yap_gcl(Yap_Error_Size, 3, ENV, P)) {
|
||||||
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Yap_unify(ARG2,TermDB)) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
ap = cl->ClPred;
|
||||||
|
return Yap_unify(GetDBLUKey(ap), ARG1);
|
||||||
}
|
}
|
||||||
ap = cl->ClPred;
|
|
||||||
return Yap_unify(GetDBLUKey(ap), ARG1);
|
|
||||||
} else if (!Yap_unify(ARG2,GetDBTermFromDBEntry(ref))
|
|
||||||
|| !UnifyDBKey(ref,0,ARG1)) {
|
|
||||||
return FALSE;
|
|
||||||
} else {
|
} else {
|
||||||
return TRUE;
|
Term TermDB;
|
||||||
|
while ((TermDB = GetDBTermFromDBEntry(ref)) == (CELL)0) {
|
||||||
|
/* oops, we are in trouble, not enough stack space */
|
||||||
|
if (Yap_Error_TYPE == OUT_OF_ATTVARS_ERROR) {
|
||||||
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||||
|
if (!Yap_growglobal(NULL)) {
|
||||||
|
Yap_Error(OUT_OF_ATTVARS_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Yap_Error_TYPE = YAP_NO_ERROR;
|
||||||
|
if (!Yap_gcl(Yap_Error_Size, 3, ENV, P)) {
|
||||||
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage);
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Yap_unify(ARG2,TermDB)
|
||||||
|
|| !UnifyDBKey(ref,0,ARG1)) {
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((pe = find_lu_entry(twork)) != NULL) {
|
if ((pe = find_lu_entry(twork)) != NULL) {
|
||||||
|
@ -195,7 +195,6 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
derefa_body(d0, ptd0, copy_term_unk, copy_term_nvar);
|
derefa_body(d0, ptd0, copy_term_unk, copy_term_nvar);
|
||||||
if (ptd0 >= HLow && ptd0 < H) {
|
if (ptd0 >= HLow && ptd0 < H) {
|
||||||
/* we have already found this cell */
|
/* we have already found this cell */
|
||||||
@ -1366,6 +1365,8 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
/* now link the two structures so that no one else will */
|
/* now link the two structures so that no one else will */
|
||||||
/* come here */
|
/* come here */
|
||||||
to_visit -= 4;
|
to_visit -= 4;
|
||||||
|
if ((CELL *)to_visit < H+1024)
|
||||||
|
goto out_of_stack;
|
||||||
to_visit[0] = pt0;
|
to_visit[0] = pt0;
|
||||||
to_visit[1] = pt0_end;
|
to_visit[1] = pt0_end;
|
||||||
to_visit[2] = pt1;
|
to_visit[2] = pt1;
|
||||||
@ -1375,6 +1376,8 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
/* store the terms to visit */
|
/* store the terms to visit */
|
||||||
if (pt0 < pt0_end) {
|
if (pt0 < pt0_end) {
|
||||||
to_visit -= 3;
|
to_visit -= 3;
|
||||||
|
if ((CELL *)to_visit < H+1024)
|
||||||
|
goto out_of_stack;
|
||||||
to_visit[0] = pt0;
|
to_visit[0] = pt0;
|
||||||
to_visit[1] = pt0_end;
|
to_visit[1] = pt0_end;
|
||||||
to_visit[2] = pt1;
|
to_visit[2] = pt1;
|
||||||
@ -1407,6 +1410,8 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
/* now link the two structures so that no one else will */
|
/* now link the two structures so that no one else will */
|
||||||
/* come here */
|
/* come here */
|
||||||
to_visit -= 4;
|
to_visit -= 4;
|
||||||
|
if ((CELL *)to_visit < H+1024)
|
||||||
|
goto out_of_stack;
|
||||||
to_visit[0] = pt0;
|
to_visit[0] = pt0;
|
||||||
to_visit[1] = pt0_end;
|
to_visit[1] = pt0_end;
|
||||||
to_visit[2] = pt1;
|
to_visit[2] = pt1;
|
||||||
@ -1416,6 +1421,8 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
/* store the terms to visit */
|
/* store the terms to visit */
|
||||||
if (pt0 < pt0_end) {
|
if (pt0 < pt0_end) {
|
||||||
to_visit -= 3;
|
to_visit -= 3;
|
||||||
|
if ((CELL *)to_visit < H+1024)
|
||||||
|
goto out_of_stack;
|
||||||
to_visit[0] = pt0;
|
to_visit[0] = pt0;
|
||||||
to_visit[1] = pt0_end;
|
to_visit[1] = pt0_end;
|
||||||
to_visit[2] = pt1;
|
to_visit[2] = pt1;
|
||||||
@ -1454,7 +1461,27 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
RESET_VARIABLE(pt1);
|
RESET_VARIABLE(pt1);
|
||||||
}
|
}
|
||||||
HBREG = B->cp_h;
|
HBREG = B->cp_h;
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
|
|
||||||
|
out_of_stack:
|
||||||
|
H = HBREG;
|
||||||
|
/* untrail all bindings made by variant */
|
||||||
|
#ifdef RATIONAL_TREES
|
||||||
|
while (to_visit < (CELL **)ASP) {
|
||||||
|
pt0 = to_visit[0];
|
||||||
|
pt0_end = to_visit[1];
|
||||||
|
pt1 = to_visit[2];
|
||||||
|
*pt0 = (CELL)to_visit[3];
|
||||||
|
to_visit += 4;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
while (TR != (tr_fr_ptr)OLDTR) {
|
||||||
|
CELL *pt1 = (CELL *) TrailTerm(--TR);
|
||||||
|
RESET_VARIABLE(pt1);
|
||||||
|
}
|
||||||
|
HBREG = B->cp_h;
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
/* failure */
|
/* failure */
|
||||||
@ -1474,7 +1501,7 @@ static int variant_complex(register CELL *pt0, register CELL *pt0_end, register
|
|||||||
RESET_VARIABLE(pt1);
|
RESET_VARIABLE(pt1);
|
||||||
}
|
}
|
||||||
HBREG = B->cp_h;
|
HBREG = B->cp_h;
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Int
|
static Int
|
||||||
@ -1482,6 +1509,7 @@ p_variant(void) /* variant terms t1 and t2 */
|
|||||||
{
|
{
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
Term t2 = Deref(ARG2);
|
Term t2 = Deref(ARG2);
|
||||||
|
int out;
|
||||||
|
|
||||||
if (t1 == t2)
|
if (t1 == t2)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@ -1496,23 +1524,37 @@ p_variant(void) /* variant terms t1 and t2 */
|
|||||||
}
|
}
|
||||||
if (IsPairTerm(t1)) {
|
if (IsPairTerm(t1)) {
|
||||||
if (IsPairTerm(t2)) {
|
if (IsPairTerm(t2)) {
|
||||||
return(variant_complex(RepPair(t1)-1,
|
out = variant_complex(RepPair(t1)-1,
|
||||||
RepPair(t1)+1,
|
RepPair(t1)+1,
|
||||||
RepPair(t2)-1));
|
RepPair(t2)-1);
|
||||||
|
if (out < 0) goto error;
|
||||||
}
|
}
|
||||||
else return (FALSE);
|
else return (FALSE);
|
||||||
}
|
}
|
||||||
if (!IsApplTerm(t2)) return(FALSE);
|
if (!IsApplTerm(t2)) {
|
||||||
{
|
return FALSE;
|
||||||
|
} else {
|
||||||
Functor f1 = FunctorOfTerm(t1);
|
Functor f1 = FunctorOfTerm(t1);
|
||||||
|
|
||||||
if (f1 != FunctorOfTerm(t2)) return(FALSE);
|
if (f1 != FunctorOfTerm(t2)) return(FALSE);
|
||||||
if (IsExtensionFunctor(f1)) {
|
if (IsExtensionFunctor(f1)) {
|
||||||
return(unify_extension(f1, t1, RepAppl(t1), t2));
|
return(unify_extension(f1, t1, RepAppl(t1), t2));
|
||||||
}
|
}
|
||||||
return(variant_complex(RepAppl(t1),
|
out = variant_complex(RepAppl(t1),
|
||||||
RepAppl(t1)+ArityOfFunctor(f1),
|
RepAppl(t1)+ArityOfFunctor(f1),
|
||||||
RepAppl(t2)));
|
RepAppl(t2));
|
||||||
|
if (out < 0) goto error;
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
|
error:
|
||||||
|
if (out == -1) {
|
||||||
|
if (!Yap_gc(2, ENV, P)) {
|
||||||
|
Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in variant");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return p_variant();
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int subsumes_complex(register CELL *pt0, register CELL *pt0_end, register
|
static int subsumes_complex(register CELL *pt0, register CELL *pt0_end, register
|
||||||
|
Reference in New Issue
Block a user