diff --git a/C/grow.c b/C/grow.c index 65fb73720..df1cf62e1 100644 --- a/C/grow.c +++ b/C/grow.c @@ -1518,7 +1518,7 @@ Yap_growtrail_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep) CELL ** Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp) { -#if USE_SYSTEM_MALLOC || USE_DL_MALLOC +#if USE_SYSTEM_MALLOC CELL **to_visit_max = *to_visit_maxp; Int sz1 = (CELL)to_visit_max-(CELL)to_visit; Int sz0 = AuxTop - (ADDR)to_visit_maxp, sz, dsz; diff --git a/C/utilpreds.c b/C/utilpreds.c index f518ca941..e555c90e1 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -521,6 +521,9 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter vars_in_term_nvar: { if (IsPairTerm(d0)) { + if (to_visit + 1024 >= (CELL **)AuxSp) { + goto aux_overflow; + } #ifdef RATIONAL_TREES to_visit[0] = pt0; to_visit[1] = pt0_end; @@ -547,6 +550,9 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter continue; } /* store the terms to visit */ + if (to_visit + 1024 >= (CELL **)AuxSp) { + goto aux_overflow; + } #ifdef RATIONAL_TREES to_visit[0] = pt0; to_visit[1] = pt0_end; @@ -633,6 +639,21 @@ static Term vars_in_complex_term(register CELL *pt0, register CELL *pt0_end, Ter H = InitialH; return 0L; + aux_overflow: + Yap_Error_Size = (to_visit-to_visit0)*sizeof(CELL **); +#ifdef RATIONAL_TREES + while (to_visit > to_visit0) { + to_visit -= 3; + pt0 = to_visit[0]; + *pt0 = (CELL)to_visit[2]; + } +#endif + Yap_Error_TYPE = OUT_OF_AUXSPACE_ERROR; + clean_tr(TR0); + Yap_ReleasePreAllocCodeSpace((ADDR)to_visit0); + H = InitialH; + return 0L; + global_overflow: #ifdef RATIONAL_TREES while (to_visit > to_visit0) { @@ -663,6 +684,13 @@ expand_vts(void) if (!Yap_growtrail(expand, FALSE)) { return FALSE; } + } else if (yap_errno == OUT_OF_AUXSPACE_ERROR) { + /* Aux space overflow */ + if (expand > 4*1024*1024) + expand = 4*1024*1024; + if (!Yap_ExpandPreAllocCodeSpace(expand, NULL)) { + return FALSE; + } } else { if (!Yap_gcl(expand, 3, ENV, P)) { Yap_Error(OUT_OF_STACK_ERROR, TermNil, "in term_variables"); diff --git a/changes-5.1.html b/changes-5.1.html index e19369632..b500f552a 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -17,6 +17,10 @@

Yap-5.1.3: