fix overflow when copying terms with attributes
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@430 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
8d579bb35d
commit
bd654f1e18
@ -1807,7 +1807,7 @@ absmi(int inp)
|
||||
/* find something to fool S */
|
||||
if (CFREG == Unsigned(LCL0) && ReadTimedVar(WokenGoals) != TermNil) {
|
||||
SREG = (CELL *)RepPredProp(GetPredPropByFunc(MkFunctor(AtomRestoreRegs,2),0));
|
||||
XREGS[0] = XREG(PREG->u.y.y);
|
||||
XREGS[0] = Y[PREG->u.y.y];
|
||||
PREG = NEXTOP(PREG,y);
|
||||
goto creep_either;
|
||||
}
|
||||
|
48
C/attvar.c
48
C/attvar.c
@ -158,26 +158,7 @@ AttVarToTerm(CELL *orig)
|
||||
static int
|
||||
TermToAttVar(Term attvar, Term to)
|
||||
{
|
||||
int i = 0;
|
||||
int open = FALSE;
|
||||
|
||||
while (IsPairTerm(attvar)) {
|
||||
Term t = HeadOfTerm(attvar);
|
||||
if (!IsVarTerm(t)) {
|
||||
if (open) {
|
||||
attvar_record *attv = (attvar_record *)VarOfTerm(Deref(to));
|
||||
if (!PutAtt(attv, i, t))
|
||||
return(FALSE);
|
||||
} else {
|
||||
if (!BuildNewAttVar(to, i, t))
|
||||
return(FALSE);
|
||||
open = TRUE;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
attvar = TailOfTerm(attvar);
|
||||
}
|
||||
return(TRUE);
|
||||
return(BuildNewAttVar(to, -1, attvar));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -369,11 +350,13 @@ BuildNewAttVar(Term t, Int i, Term tatt)
|
||||
|
||||
attvar_record *attv = (attvar_record *)ReadTimedVar(DelayedVars);
|
||||
if (H0 - (CELL *)attv < 1024+(2*NUM_OF_ATTS)) {
|
||||
ARG1 = t;
|
||||
ARG2 = tatt;
|
||||
H[0] = t;
|
||||
H[1] = tatt;
|
||||
H += 2;
|
||||
growglobal();
|
||||
t = ARG1;
|
||||
tatt = ARG2;
|
||||
H -= 2;
|
||||
t = H[0];
|
||||
tatt = H[1];
|
||||
}
|
||||
time = InitVarTime();
|
||||
RESET_VARIABLE(&(attv->Value));
|
||||
@ -386,7 +369,22 @@ BuildNewAttVar(Term t, Int i, Term tatt)
|
||||
attv->NS = UpdateTimedVar(AttsMutableList, (CELL)&(attv->Done));
|
||||
Bind((CELL *)t,(CELL)attv);
|
||||
UpdateTimedVar(DelayedVars,(CELL)(attv->Atts+2*j));
|
||||
return(PutAtt(attv, i, tatt));
|
||||
/* if i < 0 then we have the list of arguments */
|
||||
if (i < 0) {
|
||||
Int j = 0;
|
||||
while (IsPairTerm(tatt)) {
|
||||
Term t = HeadOfTerm(tatt);
|
||||
/* I need to do this because BuildNewAttVar may shift the stacks */
|
||||
if (!IsVarTerm(t)) {
|
||||
attv->Atts[2*j+1] = t;
|
||||
}
|
||||
j++;
|
||||
tatt = TailOfTerm(tatt);
|
||||
}
|
||||
return(TRUE);
|
||||
} else {
|
||||
return(PutAtt(attv, i, tatt));
|
||||
}
|
||||
}
|
||||
|
||||
static Int
|
||||
|
2
C/exec.c
2
C/exec.c
@ -1224,7 +1224,7 @@ p_restore_regs2(void)
|
||||
if (pt0 > B) {
|
||||
/* Wow, we're gonna cut!!! */
|
||||
#ifdef YAPOR
|
||||
CUT_prune_to((choiceptr) d0);
|
||||
CUT_prune_to(pt0);
|
||||
#else
|
||||
B = pt0;
|
||||
#endif /* YAPOR */
|
||||
|
@ -113,9 +113,10 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
|
||||
|
||||
vsc_count++;
|
||||
/* if (vsc_count < 84600) return; */
|
||||
/* if (vsc_count == 6469) {
|
||||
printf("Here I go\n");
|
||||
}
|
||||
/*
|
||||
if (vsc_count == 4376) {
|
||||
printf("Here I go\n");
|
||||
}
|
||||
*/
|
||||
/* if (vsc_count > 500000) exit(0); */
|
||||
/* if (gc_calls < 1) return;*/
|
||||
|
Reference in New Issue
Block a user