fix overflow of attributed variables in copy_term

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1126 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2004-09-07 20:20:12 +00:00
parent 2068026152
commit 040280ea73
3 changed files with 37 additions and 31 deletions

View File

@ -366,6 +366,7 @@ BuildNewAttVar(Term t, Int i, Term tatt)
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
Bind((CELL *)t,(CELL)attv);
Yap_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
/* avoid trouble in gc */
/* if i < 0 then we have the list of arguments */
if (i < 0) {
Int j = 0;

View File

@ -254,8 +254,8 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
/* restore our nice, friendly, term to its original state */
HB = HB0;
clean_dirty_tr(TR0);
return(0);
reset_trail(TR0);
return 0;
overflow:
/* oops, we're in trouble */
@ -272,8 +272,8 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
*pt0 = (CELL)to_visit[3];
}
#endif
clean_dirty_tr(TR0);
return(-1);
reset_trail(TR0);
return -1;
heap_overflow:
/* oops, we're in trouble */
@ -291,7 +291,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
}
#endif
clean_dirty_tr(TR0);
return(-2);
return -2;
}
static Term

View File

@ -369,39 +369,44 @@ Unification Routines
EXTERN Int STD_PROTO(Yap_unify,(Term,Term));
EXTERN inline void
reset_trail(tr_fr_ptr TR0) {
while(TR != TR0) {
CELL d1;
--TR;
d1 = TrailTerm(TR);
#ifdef MULTI_ASSIGNMENT_VARIABLES
if (IsVarTerm(d1)) {
#endif
CELL *pt = (CELL *)d1;
RESET_VARIABLE(pt);
#ifdef MULTI_ASSIGNMENT_VARIABLES
} else {
CELL *pt = RepAppl(d1);
/* AbsAppl means */
/* multi-assignment variable */
/* so the next cell is the old value */
#if FROZEN_STACKS
pt[0] = TrailVal(TR-1);
#else
pt[0] = TrailTerm(TR-1);
#endif /* FROZEN_STACKS */
TR -= 2;
}
#endif
}
}
EXTERN inline
Int Yap_unify(Term t0, Term t1)
{
tr_fr_ptr TR0 = TR;
if (Yap_IUnify(t0,t1)) {
return(TRUE);
return TRUE;
} else {
while(TR != TR0) {
CELL d1;
--TR;
d1 = TrailTerm(TR);
#ifdef MULTI_ASSIGNMENT_VARIABLES
if (IsVarTerm(d1)) {
#endif
CELL *pt = (CELL *)d1;
RESET_VARIABLE(pt);
#ifdef MULTI_ASSIGNMENT_VARIABLES
} else {
CELL *pt = RepAppl(d1);
/* AbsAppl means */
/* multi-assignment variable */
/* so the next cell is the old value */
#if FROZEN_STACKS
pt[0] = TrailVal(TR-1);
#else
pt[0] = TrailTerm(TR-1);
#endif /* FROZEN_STACKS */
TR -= 2;
}
#endif
}
return(FALSE);
reset_trail(TR0);
return FALSE;
}
}