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:
parent
2068026152
commit
040280ea73
@ -366,6 +366,7 @@ BuildNewAttVar(Term t, Int i, Term tatt)
|
|||||||
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
|
attv->NS = Yap_UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
|
||||||
Bind((CELL *)t,(CELL)attv);
|
Bind((CELL *)t,(CELL)attv);
|
||||||
Yap_UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
|
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 then we have the list of arguments */
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
Int j = 0;
|
Int j = 0;
|
||||||
|
@ -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 */
|
/* restore our nice, friendly, term to its original state */
|
||||||
HB = HB0;
|
HB = HB0;
|
||||||
clean_dirty_tr(TR0);
|
reset_trail(TR0);
|
||||||
return(0);
|
return 0;
|
||||||
|
|
||||||
overflow:
|
overflow:
|
||||||
/* oops, we're in trouble */
|
/* 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];
|
*pt0 = (CELL)to_visit[3];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
clean_dirty_tr(TR0);
|
reset_trail(TR0);
|
||||||
return(-1);
|
return -1;
|
||||||
|
|
||||||
heap_overflow:
|
heap_overflow:
|
||||||
/* oops, we're in trouble */
|
/* oops, we're in trouble */
|
||||||
@ -291,7 +291,7 @@ copy_complex_term(register CELL *pt0, register CELL *pt0_end, CELL *ptf, CELL *H
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
clean_dirty_tr(TR0);
|
clean_dirty_tr(TR0);
|
||||||
return(-2);
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Term
|
static Term
|
||||||
|
57
H/amiops.h
57
H/amiops.h
@ -369,39 +369,44 @@ Unification Routines
|
|||||||
|
|
||||||
EXTERN Int STD_PROTO(Yap_unify,(Term,Term));
|
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
|
EXTERN inline
|
||||||
Int Yap_unify(Term t0, Term t1)
|
Int Yap_unify(Term t0, Term t1)
|
||||||
{
|
{
|
||||||
tr_fr_ptr TR0 = TR;
|
tr_fr_ptr TR0 = TR;
|
||||||
|
|
||||||
if (Yap_IUnify(t0,t1)) {
|
if (Yap_IUnify(t0,t1)) {
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
while(TR != TR0) {
|
reset_trail(TR0);
|
||||||
CELL d1;
|
return FALSE;
|
||||||
--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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user