more fixes for overflows in copy_term with attributed variables (not necessarily).
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1131 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
		| @@ -81,7 +81,7 @@ CopyAttVar(CELL *orig, CELL ***to_visit_ptr, CELL *res) | |||||||
|   /* add a new attributed variable */ |   /* add a new attributed variable */ | ||||||
|   newv = (attvar_record *)Yap_ReadTimedVar(DelayedVars); |   newv = (attvar_record *)Yap_ReadTimedVar(DelayedVars); | ||||||
|   if (H0 - (CELL *)newv < 1024+(2*NUM_OF_ATTS)) |   if (H0 - (CELL *)newv < 1024+(2*NUM_OF_ATTS)) | ||||||
|     return(FALSE); |     return FALSE; | ||||||
|   RESET_VARIABLE(&(newv->Done)); |   RESET_VARIABLE(&(newv->Done)); | ||||||
|   newv->sus_id = attvars_ext; |   newv->sus_id = attvars_ext; | ||||||
|   RESET_VARIABLE(&(newv->Value)); |   RESET_VARIABLE(&(newv->Value)); | ||||||
|   | |||||||
| @@ -120,6 +120,8 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args) | |||||||
|   /*  extern int gc_calls; */ |   /*  extern int gc_calls; */ | ||||||
|  |  | ||||||
|   vsc_count++; |   vsc_count++; | ||||||
|  |   if (vsc_count < 464900) | ||||||
|  |     return; | ||||||
| #ifdef COMMENTED | #ifdef COMMENTED | ||||||
|   //  if (vsc_count == 218280) |   //  if (vsc_count == 218280) | ||||||
|   //    vsc_xstop = 1; |   //    vsc_xstop = 1; | ||||||
|   | |||||||
| @@ -64,6 +64,7 @@ clean_dirty_tr(tr_fr_ptr TR0) { | |||||||
|       if (IsVarTerm(p)) { |       if (IsVarTerm(p)) { | ||||||
| 	RESET_VARIABLE(p); | 	RESET_VARIABLE(p); | ||||||
|       } else { |       } else { | ||||||
|  | 	/* copy downwards */ | ||||||
| 	TrailTerm(TR0+1) = TrailTerm(pt); | 	TrailTerm(TR0+1) = TrailTerm(pt); | ||||||
| 	TrailTerm(TR0) = TrailTerm(TR0+2) = p; | 	TrailTerm(TR0) = TrailTerm(TR0+2) = p; | ||||||
| 	pt+=2; | 	pt+=2; | ||||||
| @@ -254,7 +255,7 @@ 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; | ||||||
|   reset_trail(TR0); |   clean_dirty_tr(TR0); | ||||||
|   return 0; |   return 0; | ||||||
|  |  | ||||||
|  overflow: |  overflow: | ||||||
| @@ -290,7 +291,7 @@ 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 -2; |   return -2; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -309,20 +310,20 @@ CopyTerm(Term inp) { | |||||||
|       Hi = H+1; |       Hi = H+1; | ||||||
|       H += 2; |       H += 2; | ||||||
|       if ((res = copy_complex_term(Hi-2, Hi-1, Hi, Hi)) < 0) { |       if ((res = copy_complex_term(Hi-2, Hi-1, Hi, Hi)) < 0) { | ||||||
| 	ARG1 = t; | 	ARG3 = t; | ||||||
| 	if (res == -1) { /* handle overflow */ | 	if (res == -1) { /* handle overflow */ | ||||||
| 	  if (!Yap_gc(2, ENV, P)) { | 	  if (!Yap_gc(3, ENV, P)) { | ||||||
| 	    Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); | 	    Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); | ||||||
| 	    return(FALSE); | 	    return(FALSE); | ||||||
| 	  } | 	  } | ||||||
| 	  t = Deref(ARG1); | 	  t = Deref(ARG3); | ||||||
| 	  goto restart_attached; | 	  goto restart_attached; | ||||||
| 	} else { /* handle overflow */ | 	} else { /* handle overflow */ | ||||||
| 	  if (!Yap_ExpandPreAllocCodeSpace(0)) { | 	  if (!Yap_ExpandPreAllocCodeSpace(0)) { | ||||||
| 	    Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); | 	    Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); | ||||||
| 	    return(FALSE); | 	    return(FALSE); | ||||||
| 	  } | 	  } | ||||||
| 	  t = Deref(ARG1); | 	  t = Deref(ARG3); | ||||||
| 	  goto restart_attached; | 	  goto restart_attached; | ||||||
| 	} | 	} | ||||||
|       } |       } | ||||||
| @@ -345,20 +346,20 @@ CopyTerm(Term inp) { | |||||||
|     { |     { | ||||||
|       int res; |       int res; | ||||||
|       if ((res = copy_complex_term(ap-1, ap+1, Hi, Hi)) < 0) { |       if ((res = copy_complex_term(ap-1, ap+1, Hi, Hi)) < 0) { | ||||||
| 	ARG1 = t; | 	ARG3 = t; | ||||||
| 	if (res == -1) { /* handle overflow */ | 	if (res == -1) { /* handle overflow */ | ||||||
| 	  if (!Yap_gc(2, ENV, P)) { | 	  if (!Yap_gc(3, ENV, P)) { | ||||||
| 	    Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); | 	    Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); | ||||||
| 	    return(FALSE); | 	    return(FALSE); | ||||||
| 	  } | 	  } | ||||||
| 	  t = Deref(ARG1); | 	  t = Deref(ARG3); | ||||||
| 	  goto restart_list; | 	  goto restart_list; | ||||||
| 	} else { /* handle overflow */ | 	} else { /* handle overflow */ | ||||||
| 	  if (!Yap_ExpandPreAllocCodeSpace(0)) { | 	  if (!Yap_ExpandPreAllocCodeSpace(0)) { | ||||||
| 	    Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); | 	    Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); | ||||||
| 	    return(FALSE); | 	    return(FALSE); | ||||||
| 	  } | 	  } | ||||||
| 	  t = Deref(ARG1); | 	  t = Deref(ARG3); | ||||||
| 	  goto restart_list; | 	  goto restart_list; | ||||||
| 	} | 	} | ||||||
|       } |       } | ||||||
| @@ -380,20 +381,20 @@ CopyTerm(Term inp) { | |||||||
|     { |     { | ||||||
|       int res; |       int res; | ||||||
|       if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), HB0+1, HB0)) < 0) { |       if ((res = copy_complex_term(ap, ap+ArityOfFunctor(f), HB0+1, HB0)) < 0) { | ||||||
| 	ARG1 = t; | 	ARG3 = t; | ||||||
| 	if (res == -1) { | 	if (res == -1) { | ||||||
| 	  if (!Yap_gc(2, ENV, P)) { | 	  if (!Yap_gc(3, ENV, P)) { | ||||||
| 	    Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); | 	    Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); | ||||||
| 	    return(FALSE); | 	    return(FALSE); | ||||||
| 	  } | 	  } | ||||||
| 	  t = Deref(ARG1); | 	  t = Deref(ARG3); | ||||||
| 	  goto restart_appl; | 	  goto restart_appl; | ||||||
| 	} else { /* handle overflow */ | 	} else { /* handle overflow */ | ||||||
| 	  if (!Yap_ExpandPreAllocCodeSpace(0)) { | 	  if (!Yap_ExpandPreAllocCodeSpace(0)) { | ||||||
| 	    Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); | 	    Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); | ||||||
| 	    return(FALSE); | 	    return(FALSE); | ||||||
| 	  } | 	  } | ||||||
| 	  t = Deref(ARG1); | 	  t = Deref(ARG3); | ||||||
| 	  goto restart_appl; | 	  goto restart_appl; | ||||||
| 	} | 	} | ||||||
|       } |       } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user