fix overflow

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1969 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2007-10-28 11:23:41 +00:00
parent 9e9c260f7e
commit 22c5632a53
5 changed files with 75 additions and 25 deletions

View File

@ -10,8 +10,13 @@
* *
* File: absmi.c *
* comments: Portable abstract machine interpreter *
* Last rev: $Date: 2007-10-28 00:54:09 $,$Author: vsc $ *
* Last rev: $Date: 2007-10-28 11:23:39 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.226 2007/10/28 00:54:09 vsc
* new version of viterbi implementation
* fix all:atvars reporting bad info
* fix bad S info in x86_64
*
* Revision 1.225 2007/10/17 09:18:26 vsc
* growtrail assumed SREG meant ASP?
*
@ -2655,8 +2660,14 @@ Yap_absmi(int inp)
BOp(call, sla);
#ifdef LOW_LEVEL_TRACER
if (Yap_do_low_level_trace)
if (Yap_do_low_level_trace) {
extern long long int vsc_count;
if (vsc_count == 165491LL) {
fprintf(stderr,"%p:%p\n",PREG,PREG->u.sla.sla_u.p);
}
low_level_trace(enter_pred,PREG->u.sla.sla_u.p,XREGS+1);
}
#endif /* LOW_LEVEL_TRACER */
CACHE_Y_AS_ENV(YREG);
{

View File

@ -374,6 +374,9 @@ static int non_ground_complex(register CELL *pt0,
goto var_found;
}
if (IsPairTerm(d0)) {
if (to_visit + 1024 >= (CELL **)AuxSp) {
goto aux_overflow;
}
#ifdef RATIONAL_TREES
to_visit[0] = pt0;
to_visit[1] = pt0_end;
@ -402,6 +405,9 @@ static int non_ground_complex(register CELL *pt0,
if (IsExtensionFunctor(f)) {
continue;
}
if (to_visit + 1024 >= (CELL **)AuxSp) {
goto aux_overflow;
}
#ifdef RATIONAL_TREES
to_visit[0] = pt0;
to_visit[1] = pt0_end;
@ -440,7 +446,7 @@ static int non_ground_complex(register CELL *pt0,
/* the term is ground */
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
return(FALSE);
return FALSE;
var_found:
/* the term is non-ground */
@ -454,31 +460,57 @@ static int non_ground_complex(register CELL *pt0,
}
#endif
/* the system will take care of TR for me, no need to worry here! */
return(TRUE);
return TRUE;
aux_overflow:
/* unwind stack */
Yap_ReleasePreAllocCodeSpace((ADDR)to_visit);
#ifdef RATIONAL_TREES
while (to_visit > (CELL **)to_visit_base) {
to_visit -= 3;
pt0 = to_visit[0];
*pt0 = (CELL)to_visit[2];
}
#endif
return -1;
}
static int
non_ground(Term t, Term *Var)
{
t = Deref(t);
if (IsVarTerm(t)) {
/* we found a variable */
*Var = t;
return(TRUE);
}
if (IsPrimitiveTerm(t)) {
return(FALSE);
} else if (IsPairTerm(t)) {
return(non_ground_complex(RepPair(t)-1, RepPair(t)+1, Var));
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
return(FALSE);
int out = -1;
while (out < 0) {
t = Deref(t);
if (IsVarTerm(t)) {
/* we found a variable */
*Var = t;
return TRUE;
}
return(non_ground_complex(RepAppl(t),
RepAppl(t)+ArityOfFunctor(FunctorOfTerm(t)),
Var));
if (IsPrimitiveTerm(t)) {
return FALSE;
} else if (IsPairTerm(t)) {
out = non_ground_complex(RepPair(t)-1, RepPair(t)+1, Var);
if (out >= 0)
return out;
} else {
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
return FALSE;
}
out = non_ground_complex(RepAppl(t),
RepAppl(t)+ArityOfFunctor(FunctorOfTerm(t)),
Var);
if (out >= 0)
return out;
}
extern int Yap_do_low_level_trace;
Yap_do_low_level_trace=1;
if (!Yap_ExpandPreAllocCodeSpace(0, NULL)) {
Yap_Error(OUT_OF_AUXSPACE_ERROR, ARG1, "overflow in ground");
return FALSE;
}
}
return FALSE;
}
#endif

View File

@ -11,8 +11,11 @@
* File: index.c *
* comments: Indexing a Prolog predicate *
* *
* Last rev: $Date: 2007-09-22 08:38:05 $,$Author: vsc $ *
* Last rev: $Date: 2007-10-28 11:23:40 $,$Author: vsc $ *
* $Log: not supported by cvs2svn $
* Revision 1.187 2007/09/22 08:38:05 vsc
* nb_ extra stuff plus an indexing overflow fix.
*
* Revision 1.186 2007/06/20 13:48:45 vsc
* fix bug in index emulator
*
@ -6494,8 +6497,9 @@ static_clause(yamop *ipc, PredEntry *ap)
ipc = PREVOP(ipc, ld);
p = (CELL *)ipc;
while ((c = ClauseCodeToStaticClause(p))) {
UInt fls = c->ClFlags & ~HasBlobsMask;
if ((fls & StaticMask) == StaticMask) {
UInt fls = c->ClFlags;
if ((fls & StaticMask) == StaticMask &&
!(fls & (MegaMask|SwitchRootMask|SwitchTableMask|DynamicMask|IndexMask|DBClMask|LogUpdMask|LogUpdRuleMask|DirtyMask))) {
if (ap->PredFlags & SourcePredFlag) {
if ((char *)c->usc.ClSource < (char *)c+c->ClSize &&
valid_instructions(ipc, c->ClCode))

View File

@ -7,7 +7,6 @@ professor_popularity(p5,l) :- {}.
professor_popularity(p45,h) :- {}.
professor_popularity(p15,m) :- {}.
:- start_low_level_trace.
course_rating(c0, h) :- {}.
course_rating(c1, m) :- {}.
course_rating(c2, l) :- {}.

View File

@ -17,6 +17,10 @@
<h2>Yap-5.1.3:</h2>
<ul>
<li> FIXED: overflow when copying constraints.</li>
<li> FIXED: MkBlob should try to allocate more space.</li>
<li> FIXED: make viterbi more efficient by not generating the whole graph.</li>
<li> FIXED: make static_clause more careful about when static clauses begin.</li>
<li> NEW: support conditional compilation using if/1,elif/1,else/0,endif/0 directives.</li>
<li> FIXED: delay abort until garbage collection or stack shifting is over.</li>
<li> FIXED: grow_trail assumed SREG points to stack top!</li>