diff --git a/C/absmi.c b/C/absmi.c index 2bea1c218..d120ea521 100755 --- a/C/absmi.c +++ b/C/absmi.c @@ -2068,6 +2068,11 @@ Yap_absmi(int inp) #endif /* FROZEN_STACKS */ if (IN_BETWEEN(H0,pt1,H) && IsAttVar(pt1)) goto failloop; +#ifdef FROZEN_STACKS /* TRAIL */ + /* don't reset frozen variables */ + if (pt0 < TR_FZ) + goto failloop; +#endif flags = *pt1; #if MULTIPLE_STACKS if (FlagOn(DBClMask, flags)) { diff --git a/C/alloc.c b/C/alloc.c index e5796a14d..4d0b5362a 100755 --- a/C/alloc.c +++ b/C/alloc.c @@ -153,6 +153,7 @@ call_malloc(unsigned long int size) char * Yap_AllocCodeSpace(unsigned long int size) { + size = AdjustSize(size); return call_malloc(size); } @@ -186,6 +187,7 @@ call_realloc(char *p, unsigned long int size) char * Yap_ReallocCodeSpace(char *p, unsigned long int size) { + size = AdjustSize(size); return call_realloc(p, size); } @@ -211,6 +213,7 @@ Yap_FreeCodeSpace(char *p) char * Yap_AllocAtomSpace(unsigned long int size) { + size = AdjustSize(size); return call_malloc(size); } diff --git a/C/arrays.c b/C/arrays.c index 2114aa77d..43f103ed9 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -170,8 +170,10 @@ CloseMmappedArray(StaticArrayEntry *pp, void *area USES_REGS) optr = ptr; } if (ptr == NULL) { +#if !defined(USE_SYSTEM_MALLOC) Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (array chain incoherent)", strerror(errno)); - return(FALSE); +#endif + return FALSE; } if (munmap(ptr->start, ptr->size) == -1) { Yap_Error(SYSTEM_ERROR,ARG1,"close_mmapped_array (munmap: %s)", strerror(errno)); @@ -1240,7 +1242,11 @@ p_close_static_array( USES_REGS1 ) #if HAVE_MMAP if (ptr->ValueOfVE.chars < (char *)Yap_HeapBase || ptr->ValueOfVE.chars > (char *)HeapTop) { - return(CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS)); + Int val = CloseMmappedArray(ptr, (void *)ptr->ValueOfVE.chars PASS_REGS); +#if USE_SYSTEM_MALLOC + if (val) +#endif + return(val); } #endif Yap_FreeAtomSpace((char *)(ptr->ValueOfVE.ints)); diff --git a/C/exec.c b/C/exec.c index 935f35793..8024fb95f 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1018,6 +1018,9 @@ init_stack(int arity, CELL *pt, int top, choiceptr saved_b USES_REGS) YENV[E_CP] = (CELL)P; YENV[E_CB] = (CELL)B; YENV[E_E] = (CELL)ENV; +#ifdef TABLING + YENV[E_B] = (CELL)B; +#endif #ifdef DEPTH_LIMIT YENV[E_DEPTH] = DEPTH; #endif @@ -1621,6 +1624,7 @@ Yap_InitYaamRegs(void) if (Yap_AttsSize > (Yap_LocalBase-Yap_GlobalBase)/8) Yap_AttsSize = (Yap_LocalBase-Yap_GlobalBase)/8; H = H0 = ((CELL *) Yap_GlobalBase)+ Yap_AttsSize/sizeof(CELL); + RESET_VARIABLE(H0-1); LCL0 = ASP = (CELL *) Yap_LocalBase; /* notice that an initial choice-point and environment *must* be created since for the garbage collector to work */