fix overflow handling in loop checking for unify_occurs_check (UN #232)

This commit is contained in:
Vítor Santos Costa 2012-03-15 22:37:13 +00:00
parent 0c1eb1d642
commit 919fa40464
4 changed files with 15 additions and 12 deletions

View File

@ -1783,7 +1783,7 @@ Yap_growtrail_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep)
} }
CELL ** CELL **
Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp) Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp, CELL ***to_visit_base)
{ {
CACHE_REGS CACHE_REGS
CELL **to_visit_max = *to_visit_maxp; CELL **to_visit_max = *to_visit_maxp;
@ -1817,6 +1817,9 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp)
cpcellsd((CELL *)(newb+(dsz+szlow)), (CELL *)(newb+szlow), sz/sizeof(CELL)); cpcellsd((CELL *)(newb+(dsz+szlow)), (CELL *)(newb+szlow), sz/sizeof(CELL));
/* base pointer is block start */ /* base pointer is block start */
*to_visit_maxp = (CELL **)(newb+szlow); *to_visit_maxp = (CELL **)(newb+szlow);
/* base pointer is block start */
if (to_visit_base)
*to_visit_base = (CELL **)AuxSp;
/* current top is originall diff + diff size */ /* current top is originall diff + diff size */
return (CELL **)(newb+(off+dsz)); return (CELL **)(newb+(off+dsz));
} }

View File

@ -54,7 +54,7 @@ rtree_loop:
if (IsPairTerm(d0)) { if (IsPairTerm(d0)) {
to_visit -= 3; to_visit -= 3;
if (to_visit < to_visit_max) { if (to_visit < to_visit_max) {
to_visit = Yap_shift_visit(to_visit, &to_visit_max); to_visit = Yap_shift_visit(to_visit, &to_visit_max, &base);
} }
to_visit[0] = pt0; to_visit[0] = pt0;
to_visit[1] = pt0_end; to_visit[1] = pt0_end;
@ -76,7 +76,7 @@ rtree_loop:
} }
to_visit -= 3; to_visit -= 3;
if (to_visit < to_visit_max) { if (to_visit < to_visit_max) {
to_visit = Yap_shift_visit(to_visit, &to_visit_max); to_visit = Yap_shift_visit(to_visit, &to_visit_max, &base);
} }
to_visit[0] = pt0; to_visit[0] = pt0;
to_visit[1] = pt0_end; to_visit[1] = pt0_end;
@ -192,7 +192,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;
@ -237,7 +237,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;
@ -672,7 +672,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;
@ -717,7 +717,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;

View File

@ -209,7 +209,7 @@ int STD_PROTO(Yap_growheap, (int, UInt, void *));
int STD_PROTO(Yap_growstack, (long)); int STD_PROTO(Yap_growstack, (long));
int STD_PROTO(Yap_growtrail, (long, int)); int STD_PROTO(Yap_growtrail, (long, int));
int STD_PROTO(Yap_growglobal, (CELL **)); int STD_PROTO(Yap_growglobal, (CELL **));
CELL **STD_PROTO(Yap_shift_visit, (CELL **, CELL ***)); CELL **STD_PROTO(Yap_shift_visit, (CELL **, CELL ***, CELL ***));
#ifdef THREADS #ifdef THREADS
void STD_PROTO(Yap_CopyThreadStacks, (int, int, int)); void STD_PROTO(Yap_CopyThreadStacks, (int, int, int));
#endif #endif

View File

@ -1150,7 +1150,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;
@ -1195,7 +1195,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;
@ -1350,7 +1350,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;
@ -1395,7 +1395,7 @@ loop:
#endif #endif
if ((void *)to_visit < (void *)unif) { if ((void *)to_visit < (void *)unif) {
CELL **urec = (CELL **)unif; CELL **urec = (CELL **)unif;
to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec); to_visit = (struct v_record *)Yap_shift_visit((CELL **)to_visit, &urec, NULL);
unif = (struct unif_record *)urec; unif = (struct unif_record *)urec;
} }
to_visit->start0 = pt0; to_visit->start0 = pt0;