diff --git a/C/absmi.c b/C/absmi.c index 25ffbb1cc..6e850ca01 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -10,8 +10,11 @@ * * * File: absmi.c * * comments: Portable abstract machine interpreter * -* Last rev: $Date: 2004-11-19 17:14:12 $,$Author: vsc $ * +* Last rev: $Date: 2004-11-19 22:08:35 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.152 2004/11/19 17:14:12 vsc +* a few fixes for 64 bit compiling. +* * Revision 1.151 2004/11/04 18:22:28 vsc * don't ever use memory that has been freed (that was done by LU). * generic fixes for WIN32 libraries @@ -12617,7 +12620,7 @@ Yap_absmi(int inp) if (ActiveSignals & YAP_CDOVF_SIGNAL) { saveregs_and_ycache(); if (!Yap_growheap(FALSE, 0, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "YAP failed to grow heap: %s", Yap_ErrorMessage); setregs_and_ycache(); FAIL(); } diff --git a/C/alloc.c b/C/alloc.c index f41b3b3c9..35f472fab 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -12,7 +12,7 @@ * Last rev: * * mods: * * comments: allocating space * -* version:$Id: alloc.c,v 1.65 2004-11-17 05:24:20 vsc Exp $ * +* version:$Id: alloc.c,v 1.66 2004-11-19 22:08:40 vsc Exp $ * *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -99,7 +99,7 @@ Yap_InitPreAllocCodeSpace(void) if (ScratchPad.ptr == NULL) { while (!(ptr = malloc(sz))) if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(NULL); } ScratchPad.ptr = ptr; @@ -476,7 +476,7 @@ AllocHeap(unsigned int size) UNLOCK(HeapUsedLock); UNLOCK(HeapTopLock); /* we destroyed the stack */ - Yap_Error(SYSTEM_ERROR, TermNil, "Stack Crashed against Heap..."); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, "Stack Crashed against Heap..."); return(NULL); } else { if (HeapTop + size * sizeof(CELL) + sizeof(YAP_SEG_SIZE) < HeapLim) { diff --git a/C/amasm.c b/C/amasm.c index bf01fd1d6..2fc2ea594 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -11,8 +11,11 @@ * File: amasm.c * * comments: abstract machine assembler * * * -* Last rev: $Date: 2004-10-26 20:15:48 $ * +* Last rev: $Date: 2004-11-19 22:08:41 $ * * $Log: not supported by cvs2svn $ +* Revision 1.65 2004/10/26 20:15:48 vsc +* More bug fixes for overflow handling +* * Revision 1.64 2004/09/30 21:37:40 vsc * fixes for thread support * @@ -2968,7 +2971,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates while ((x = Yap_StoreTermInDBPlusExtraSpace(t, size)) == NULL) { *H++ = (CELL)h0; if (!Yap_growheap(TRUE, size, cip)) { - Yap_Error_TYPE = SYSTEM_ERROR; + Yap_Error_TYPE = OUT_OF_HEAP_ERROR; return NULL; } h0 = (CELL *)*--H; @@ -3024,7 +3027,7 @@ Yap_assemble(int mode, Term t, PredEntry *ap, int is_fact, struct intermediates while ((cip->code_addr = (yamop *) Yap_AllocCodeSpace(size)) == NULL) { if (!Yap_growheap(TRUE, size, cip)) { - Yap_Error_TYPE = SYSTEM_ERROR; + Yap_Error_TYPE = OUT_OF_HEAP_ERROR; return NULL; } } diff --git a/C/arrays.c b/C/arrays.c index febb7a378..36cc0ef27 100644 --- a/C/arrays.c +++ b/C/arrays.c @@ -465,7 +465,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra while ((p->ValueOfVE.floats = (Float *) Yap_AllocAtomSpace(asize) ) == NULL) { YAPLeaveCriticalSection(); if (!Yap_growheap(FALSE, asize, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return; } YAPEnterCriticalSection(); @@ -479,7 +479,7 @@ CreateStaticArray(AtomEntry *ae, Int dim, static_array_types type, CODEADDR star if (EndOfPAEntr(p)) { while ((p = (StaticArrayEntry *) Yap_AllocAtomSpace(sizeof(*p))) == NULL) { if (!Yap_growheap(FALSE, sizeof(*p), NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return NULL; } } @@ -646,7 +646,7 @@ p_create_array(void) } else { if (H+1+size > ASP-1024) { if (!Yap_growstack( sizeof(CELL) * (size+1-(H-ASP-1024)))) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return FALSE; } } @@ -1880,7 +1880,7 @@ p_static_array_to_term(void) } else { if (H+1+dim > ASP-1024) { if (!Yap_growstack( sizeof(CELL) * (dim+1-(H-ASP-1024)))) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); return FALSE; } } diff --git a/C/bb.c b/C/bb.c index 6e6876d07..b0e585b8d 100644 --- a/C/bb.c +++ b/C/bb.c @@ -41,7 +41,7 @@ PutBBProp(AtomEntry *ae, Term mod) /* get BBentry for at; */ p = (BBProp)Yap_AllocAtomSpace(sizeof(*p)); if (p == NULL) { WRITE_UNLOCK(ae->ARWLock); - Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2"); + Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); return(NULL); } p->NextOfPE = ae->PropsOfAE; @@ -73,7 +73,7 @@ PutIntBBProp(Int key, Term mod) /* get BBentry for at; */ pp++; } } else { - Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2"); + Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); return(NULL); } } @@ -90,7 +90,7 @@ PutIntBBProp(Int key, Term mod) /* get BBentry for at; */ p = (BBProp)Yap_AllocAtomSpace(sizeof(*p)); if (p == NULL) { YAPLeaveCriticalSection(); - Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space in bb_put/2"); + Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space in bb_put/2"); return(NULL); } p->ModuleOfBB = mod; @@ -160,7 +160,7 @@ resize_bb_int_keys(UInt new_size) { new = (Prop *)Yap_AllocCodeSpace(sizeof(Prop)*new_size); if (new == NULL) { YAPLeaveCriticalSection(); - Yap_Error(SYSTEM_ERROR,ARG1,"could not allocate space"); + Yap_Error(OUT_OF_HEAP_ERROR,ARG1,"could not allocate space"); return(FALSE); } for (i = 0; i < new_size; i++) { diff --git a/C/c_interface.c b/C/c_interface.c index b4fae3691..5ca1d1e7b 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -10,8 +10,13 @@ * File: c_interface.c * * comments: c_interface primitives definition * * * -* Last rev: $Date: 2004-11-18 22:32:31 $,$Author: vsc $ * +* Last rev: $Date: 2004-11-19 22:08:41 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.57 2004/11/18 22:32:31 vsc +* fix situation where we might assume nonextsing double initialisation of C predicates (use +* Hidden Pred Flag). +* $host_type was double initialised. +* * Revision 1.56 2004/10/31 02:18:03 vsc * fix bug in handling Yap heap overflow while adding new clause. * @@ -715,7 +720,7 @@ YAP_AllocSpaceFromYap(unsigned int size) if ((ptr = Yap_AllocCodeSpace(size)) == NULL) { if (!Yap_growheap(FALSE, size, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(NULL); } } diff --git a/C/compiler.c b/C/compiler.c index a164aac33..2b79eec70 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -11,8 +11,11 @@ * File: compiler.c * * comments: Clause compiler * * * -* Last rev: $Date: 2004-09-03 03:11:08 $,$Author: vsc $ * +* Last rev: $Date: 2004-11-19 22:08:41 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.53 2004/09/03 03:11:08 vsc +* memory management fixes +* * Revision 1.52 2004/07/15 17:20:23 vsc * fix error message * change makefile and configure for clpbn @@ -2770,7 +2773,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod, Term src) } if (osize > ASP-H) { if (!Yap_growstack(2*sizeof(CELL)*(ASP-H))) { - Yap_Error_TYPE = SYSTEM_ERROR; + Yap_Error_TYPE = OUT_OF_STACK_ERROR; Yap_Error_Term = my_clause; } } @@ -2791,7 +2794,7 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod, Term src) /* not enough heap */ restore_machine_regs(); reset_vars(cglobs.vtable); - Yap_Error_TYPE = SYSTEM_ERROR; + Yap_Error_TYPE = OUT_OF_HEAP_ERROR; Yap_Error_Term = TermNil; return(0); } diff --git a/C/exec.c b/C/exec.c index c9c353cc5..6df95e281 100644 --- a/C/exec.c +++ b/C/exec.c @@ -1290,7 +1290,7 @@ Yap_RunTopGoal(Term t) #if !USE_MALLOC if (Yap_TrailTop - HeapTop < 2048) { Yap_PrologMode = BootMode; - Yap_Error(SYSTEM_ERROR,TermNil, + Yap_Error(OUT_OF_TRAIL_ERROR,TermNil, "unable to boot because of too little heap space"); } #endif diff --git a/C/grow.c b/C/grow.c index 7507c8c9e..022cb760e 100644 --- a/C/grow.c +++ b/C/grow.c @@ -818,7 +818,7 @@ do_growheap(int fix_code, UInt in_size, struct intermediates *cip) sz = in_size; } #if YAPOR - Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running"); + Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow Heap: more than a worker/thread running"); return FALSE; #endif if (SizeOfOverflow > sz) @@ -959,7 +959,7 @@ Yap_growglobal(CELL **ptr) #if YAPOR if (NOfThreads != 1) { - Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Global: more than a worker/thread running"); + Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Global: more than a worker/thread running"); return(FALSE); } #endif @@ -1167,7 +1167,7 @@ Yap_growstack_in_parser(tr_fr_ptr *old_trp, TokEntry **tksp, VarEntry **vep) #if YAPOR if (NOfThreads != 1) { - Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow Parser Stack: more than a worker/thread running"); + Yap_Error(OUT_OF_STACK_ERROR,TermNil,"cannot grow Parser Stack: more than a worker/thread running"); return(FALSE); } #endif @@ -1298,7 +1298,7 @@ Yap_shift_visit(CELL **to_visit, CELL ***to_visit_maxp) cpcellsd((CELL *)dest, (CELL *)to_visit, (CELL)((CELL *)old_top-(CELL *)to_visit)); return dest; } else { - Yap_Error(SYSTEM_ERROR,TermNil,"cannot grow temporary stack for unification (%p)", Yap_TrailTop); + Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"cannot grow temporary stack for unification (%p)", Yap_TrailTop); return to_visit; } #endif diff --git a/C/heapgc.c b/C/heapgc.c index 86ccd2559..b1da43ea1 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -3338,7 +3338,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) max = (CELL *)Yap_ReadTimedVar(DelayedVars); if (H0 - max < 1024+(2*NUM_OF_ATTS)) { if (!Yap_growglobal(¤t_env)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_STACK_ERROR, TermNil, Yap_ErrorMessage); return 0; } } @@ -3397,7 +3397,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop) if (HeapTop >= Yap_GlobalBase - MinHeapGap) { *--ASP = (CELL)current_env; if (!Yap_growheap(FALSE, MinHeapGap, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } current_env = (CELL *)*ASP; diff --git a/C/index.c b/C/index.c index 76261932b..5505ae8d9 100644 --- a/C/index.c +++ b/C/index.c @@ -11,8 +11,11 @@ * File: index.c * * comments: Indexing a Prolog predicate * * * -* Last rev: $Date: 2004-11-19 17:14:14 $,$Author: vsc $ * +* Last rev: $Date: 2004-11-19 22:08:42 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.107 2004/11/19 17:14:14 vsc +* a few fixes for 64 bit compiling. +* * Revision 1.106 2004/11/18 22:32:36 vsc * fix situation where we might assume nonextsing double initialisation of C predicates (use * Hidden Pred Flag). @@ -473,7 +476,7 @@ sort_group(GroupDef *grp, CELL *top, struct intermediates *cint) longjmp(cint->CompilerBotch,4); #else if (!Yap_growtrail(2*max*CellSize)) { - Yap_Error(SYSTEM_ERROR,TermNil,"YAP failed to reserve %ld in growtrail", + Yap_Error(OUT_OF_TRAIL_ERROR,TermNil,"YAP failed to reserve %ld in growtrail", 2*max*CellSize); return; } @@ -4040,7 +4043,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots) } else if (setjres != 0) { recover_from_failed_susp_on_cls(&cint, 0); if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return FAILCODE; } } @@ -4062,7 +4065,7 @@ Yap_PredIsIndexable(PredEntry *ap, UInt NSlots) if (cint.CodeStart) { if ((indx_out = Yap_assemble(ASSEMBLING_INDEX, TermNil, ap, FALSE, &cint)) == NULL) { if (!Yap_growheap(FALSE, Yap_Error_Size, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return NULL; } goto restart_index; diff --git a/C/init.c b/C/init.c index 8dcb13625..eaa3af8a9 100644 --- a/C/init.c +++ b/C/init.c @@ -660,8 +660,8 @@ Yap_InitCPredBack(char *Name, unsigned long int Arity, unsigned int Extra, CPred pe->PredFlags |= SequentialPredFlag; #endif /* YAPOR */ cl = (StaticClause *)Yap_AllocCodeSpace((CELL)NEXTOP(NEXTOP(NEXTOP(code,lds),lds),e)); - if (cl == NIL) { - Yap_Error(SYSTEM_ERROR,TermNil,"No Heap Space in InitCPredBack"); + if (cl == NULL) { + Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCPredBack"); return; } cl->ClFlags = 0; @@ -860,8 +860,8 @@ InitCodes(void) INIT_RWLOCK(heap_regs->invisiblechain.AERWLock); heap_regs->consultlow = (consult_obj *)Yap_AllocCodeSpace(sizeof(consult_obj)*InitialConsultCapacity); - if (heap_regs->consultlow == NIL) { - Yap_Error(SYSTEM_ERROR,TermNil,"No Heap Space in InitCodes"); + if (heap_regs->consultlow == NULL) { + Yap_Error(OUT_OF_HEAP_ERROR,TermNil,"No Heap Space in InitCodes"); return; } heap_regs->consultcapacity = InitialConsultCapacity; diff --git a/C/iopreds.c b/C/iopreds.c index 07b308ea0..3bcb035a4 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -1228,7 +1228,7 @@ PipeGetc(int sno) #if _MSC_VER || defined(__MINGW32__) DWORD count; if (WriteFile(s->u.pipe.hdl, &c, sizeof(c), &count, NULL) == FALSE) { - PlIOError (SYSTEM_ERROR,TermNil, "read from pipe returned error"); + PlIOError (SYSTEM_ERROR,TermNil, "write to pipe returned error"); return(EOF); } #else @@ -2054,7 +2054,7 @@ p_open_mem_read_stream (void) /* $open_mem_read_stream(+List,-Stream) */ } while ((nbuf = (char *)Yap_AllocAtomSpace((sl+1)*sizeof(char))) == NULL) { if (!Yap_growheap(FALSE, (sl+1)*sizeof(char), NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } } @@ -2115,7 +2115,7 @@ p_open_mem_write_stream (void) /* $open_mem_write_stream(-Stream) */ while ((nbuf = (char *)Yap_AllocAtomSpace(Yap_page_size*sizeof(char))) == NULL) { if (!Yap_growheap(FALSE, Yap_page_size*sizeof(char), NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } } @@ -4550,7 +4550,7 @@ p_char_conversion(void) CharConversionTable2 = Yap_AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char)); while (CharConversionTable2 == NULL) { if (!Yap_growheap(FALSE, NUMBER_OF_CHARS*sizeof(char), NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } } diff --git a/C/save.c b/C/save.c index a9a10a338..6fe56382f 100644 --- a/C/save.c +++ b/C/save.c @@ -964,7 +964,7 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries) basep = (CELL *)TR; if (basep + (NOfE*2) > (CELL *)Yap_TrailTop) { if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-Yap_TrailTop)) { - Yap_Error(SYSTEM_ERROR, TermNil, + Yap_Error(OUT_OF_TRAIL_ERROR, TermNil, "not enough space to restore hash tables for indexing"); Yap_exit(1); } diff --git a/C/stdpreds.c b/C/stdpreds.c index 28e0b3263..91aba6c28 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -11,8 +11,11 @@ * File: stdpreds.c * * comments: General-purpose C implemented system predicates * * * -* Last rev: $Date: 2004-11-19 17:14:14 $,$Author: vsc $ * +* Last rev: $Date: 2004-11-19 22:08:43 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.73 2004/11/19 17:14:14 vsc +* a few fixes for 64 bit compiling. +* * Revision 1.72 2004/11/18 22:32:37 vsc * fix situation where we might assume nonextsing double initialisation of C predicates (use * Hidden Pred Flag). @@ -1105,7 +1108,7 @@ p_atom_concat(void) if (cptr+sz >= top-1024) { Yap_ReleasePreAllocCodeSpace((ADDR)cpt0); if (!Yap_growheap(FALSE, sz+1024, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } goto restart; @@ -1167,7 +1170,7 @@ p_atomic_concat(void) if (cptr+sz >= top-1024) { Yap_ReleasePreAllocCodeSpace((ADDR)cpt0); if (!Yap_growheap(FALSE, sz+1024, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } goto restart; @@ -1196,7 +1199,7 @@ p_atomic_concat(void) if ((sz = mpz_sizeinbase (n, 10)) > (top-cptr)-1024) { Yap_ReleasePreAllocCodeSpace((ADDR)cpt0); if (!Yap_growheap(FALSE, sz+1024, NULL)) { - Yap_Error(SYSTEM_ERROR, TermNil, Yap_ErrorMessage); + Yap_Error(OUT_OF_HEAP_ERROR, TermNil, Yap_ErrorMessage); return(FALSE); } goto restart; @@ -1361,7 +1364,7 @@ p_atom_split(void) if (len > (Int)strlen(s)) return(FALSE); for (i = 0; i< len; i++) { if (s1 > (char *)LCL0-1024) - Yap_Error(SYSTEM_ERROR,t1,"$atom_split/4"); + Yap_Error(OUT_OF_STACK_ERROR,t1,"$atom_split/4"); s1[i] = s[i]; } s1[len] = '\0';