pesky ^C and abort fixes (I hope)
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@236 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
7e22cb486f
commit
2b78d7ce14
@ -298,7 +298,7 @@ absmi(int inp)
|
||||
restore_absmi_regs(old_regs);
|
||||
#endif
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP failed to reserve space in growheap ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP failed to reserve space in growheap");
|
||||
FAIL();
|
||||
}
|
||||
goto reset_absmi;
|
||||
@ -2077,7 +2077,7 @@ absmi(int inp)
|
||||
}
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
Abort("");
|
||||
Error(PURE_ABORT, TermNil, "");
|
||||
}
|
||||
JMPNext();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.9 2001-09-24 14:35:58 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.10 2001-12-18 22:01:26 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -254,7 +254,7 @@ AllocHeap(unsigned int size)
|
||||
UNLOCK(HeapTopLock);
|
||||
}
|
||||
/* we destroyed the stack */
|
||||
Abort("Stack Crashed against Heap...");
|
||||
Error(SYSTEM_ERROR, TermNil, "Stack Crashed against Heap...");
|
||||
return(NULL);
|
||||
} else {
|
||||
if (HeapTop + size * sizeof(CELL) + sizeof(YAP_SEG_SIZE) < Addr(AuxSp)) {
|
||||
|
@ -432,7 +432,7 @@ AllocateStaticArraySpace(StaticArrayEntry *p, static_array_types atype, Int arra
|
||||
while ((p->ValueOfVE.floats = (Float *) AllocAtomSpace(asize) ) == NULL) {
|
||||
YAPLeaveCriticalSection();
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP failed to reserve space in growheap ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP failed to reserve space in growheap");
|
||||
return;
|
||||
}
|
||||
YAPEnterCriticalSection();
|
||||
|
@ -390,7 +390,7 @@ YapAllocSpaceFromYap(unsigned int size)
|
||||
|
||||
if ((ptr = AllocCodeSpace(size)) == NULL) {
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP failed to reserve space in growheap ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP failed to reserve space in growheap");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
10
C/errors.c
10
C/errors.c
@ -369,8 +369,6 @@ ShutdownYAP(int value)
|
||||
exit(value);
|
||||
}
|
||||
|
||||
static int in_error = FALSE;
|
||||
|
||||
yamop *
|
||||
Error (yap_error_number type, Term where, char *format,...)
|
||||
{
|
||||
@ -382,8 +380,10 @@ Error (yap_error_number type, Term where, char *format,...)
|
||||
char *tp = p;
|
||||
int psize = 512;
|
||||
|
||||
if (in_error)
|
||||
/* disallow recursive error handling */
|
||||
if (PrologMode & InErrorMode)
|
||||
return(P);
|
||||
PrologMode |= InErrorMode;
|
||||
va_start (ap, format);
|
||||
/* now build the error string */
|
||||
if (format != NULL)
|
||||
@ -1821,7 +1821,7 @@ Error (yap_error_number type, Term where, char *format,...)
|
||||
while (B->cp_b != NULL && B->cp_ap != (yamop *) NOCODE)
|
||||
B = B->cp_b;
|
||||
P = (yamop *)FAILCODE;
|
||||
in_error = FALSE;
|
||||
PrologMode &= ~InErrorMode;
|
||||
return(P);
|
||||
}
|
||||
/* make the abstract machine jump where we want them to jump to */
|
||||
@ -1836,7 +1836,7 @@ Error (yap_error_number type, Term where, char *format,...)
|
||||
#endif /* YAPOR */
|
||||
P = (yamop *)FAILCODE;
|
||||
}
|
||||
in_error = FALSE;
|
||||
PrologMode &= ~InErrorMode;
|
||||
return(P);
|
||||
}
|
||||
|
||||
|
@ -2118,7 +2118,7 @@ update_relocation_chain(CELL_PTR current, CELL_PTR dest)
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else {
|
||||
Abort("[GC] ATOMIC in relocation chain");
|
||||
Error(SYSTEM_ERROR, TermNil, "ATOMIC in a GC relocation chain");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -2664,7 +2664,7 @@ do_gc(Int predarity, CELL *current_env, yamop *nextop)
|
||||
if (HeapTop >= GlobalBase - MinHeapGap) {
|
||||
*--ASP = (CELL)current_env;
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap before garbage collection ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap before garbage collection");
|
||||
return(FALSE);
|
||||
}
|
||||
current_env = (CELL *)*ASP;
|
||||
|
@ -1410,7 +1410,7 @@ PredIsIndexable(PredEntry *ap)
|
||||
#endif
|
||||
if ((indx_out = assemble(ASSEMBLING_INDEX)) == NIL) {
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP failed to reserve space in growheap ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP failed to reserve space in growheap");
|
||||
return(FALSE);
|
||||
}
|
||||
goto restart_index;
|
||||
|
27
C/iopreds.c
27
C/iopreds.c
@ -635,7 +635,7 @@ MemPutc(int sno, int ch)
|
||||
char *newbuf;
|
||||
|
||||
if ((newbuf = AllocAtomSpace(new_max_size*sizeof(char))) == NULL) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap for writing to string ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap for writing to string");
|
||||
}
|
||||
#if HAVE_MEMMOVE
|
||||
memmove((void *)newbuf, (void *)s->u.mem_string.buf, (size_t)((s->u.mem_string.pos)*sizeof(char)));
|
||||
@ -912,8 +912,9 @@ ReadlineGetc(int sno)
|
||||
PrologMode &= ~InterruptMode;
|
||||
ProcessSIGINT();
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
Abort("");
|
||||
Error(PURE_ABORT, TermNil, NULL);
|
||||
ErrorMessage = "Abort";
|
||||
return(console_post_process_read_char(EOF, s, sno));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -1281,8 +1282,9 @@ ConsoleGetc(int sno)
|
||||
ProcessSIGINT();
|
||||
newline = TRUE;
|
||||
if (PrologMode & AbortMode) {
|
||||
PrologMode &= ~AbortMode;
|
||||
Abort("");
|
||||
Error(PURE_ABORT, TermNil, NULL);
|
||||
ErrorMessage = "Abort";
|
||||
return(console_post_process_read_char(EOF, s, sno));
|
||||
}
|
||||
goto restart;
|
||||
}
|
||||
@ -1929,7 +1931,7 @@ p_open_mem_read_stream (void) /* $open_mem_read_stream(+List,-Stream) */
|
||||
}
|
||||
while ((nbuf = (char *)AllocAtomSpace((sl+1)*sizeof(char))) == NULL) {
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap in open_mem_read_stream ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in open_mem_read_stream");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -1983,7 +1985,7 @@ p_open_mem_write_stream (void) /* $open_mem_write_stream(-Stream) */
|
||||
|
||||
while ((nbuf = (char *)AllocAtomSpace(page_size*sizeof(char))) == NULL) {
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap in open_mem_write_stream ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in open_mem_write_stream");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
@ -2432,7 +2434,7 @@ p_peek_mem_write_stream (void)
|
||||
while (H + 1024 >= ASP) {
|
||||
H = HI;
|
||||
if (!gc(3, ENV, P)) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow stack in peek_mem_write_stream/2 ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow stack in peek_mem_write_stream/2");
|
||||
return(FALSE);
|
||||
}
|
||||
i = 0;
|
||||
@ -2790,6 +2792,11 @@ p_read (void)
|
||||
if ((Stream[c_input_stream].status & Eof_Stream_f)
|
||||
&& !eot_before_eof) {
|
||||
if (tokstart != NIL && tokstart->Tok != Ord (eot_tok)) {
|
||||
/* we got the end of file from an abort */
|
||||
if (ErrorMessage == "Abort") {
|
||||
TR = old_TR;
|
||||
return(FALSE);
|
||||
}
|
||||
/* we need to force the next reading to also give end of file.*/
|
||||
Stream[c_input_stream].status |= Push_Eof_Stream_f;
|
||||
ErrorMessage = "[ Error: end of file found before end of term ]";
|
||||
@ -3525,7 +3532,7 @@ format_putc(int sno, int ch) {
|
||||
char *newbuf;
|
||||
|
||||
if ((newbuf = AllocAtomSpace(new_max_size*sizeof(char))) == NULL) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap for format/2 ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap for format/2");
|
||||
return(EOF);
|
||||
}
|
||||
#if HAVE_MEMMOVE
|
||||
@ -4629,7 +4636,7 @@ p_char_conversion(void)
|
||||
CharConversionTable2 = AllocCodeSpace(NUMBER_OF_CHARS*sizeof(char));
|
||||
while (CharConversionTable2 == NULL) {
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap in char_conversion/2 ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in char_conversion/2");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
|
@ -689,6 +689,9 @@ token(void)
|
||||
eat up the escape sequence. */
|
||||
ErrorMessage = "invalid escape sequence";
|
||||
}
|
||||
} else if (chtype[ch] == EF) {
|
||||
ReleasePreAllocCodeSpace((CODEADDR)TokImage);
|
||||
return (eot_tok);
|
||||
} else {
|
||||
*charp++ = ch;
|
||||
my_get_quoted_ch();
|
||||
|
@ -653,7 +653,7 @@ p_atom_concat(void)
|
||||
if (cptr+sz >= top-1024) {
|
||||
ReleasePreAllocCodeSpace((ADDR)cpt0);
|
||||
if (!growheap(FALSE)) {
|
||||
Abort("[ SYSTEM ERROR: YAP could not grow heap in recorda/3 ]\n");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP could not grow heap in recorda/3 ]\n");
|
||||
return(FALSE);
|
||||
}
|
||||
goto restart;
|
||||
|
@ -993,8 +993,7 @@ SearchForTrailFault(void)
|
||||
if ((TR > (tr_fr_ptr)TrailTop-1024 &&
|
||||
TR < (tr_fr_ptr)TrailTop+(64*1024))|| DBTrailOverflow()) {
|
||||
if (!growtrail(64 * 1024L)) {
|
||||
YP_fprintf(YP_stderr, "[ ERROR: YAP failed to reserve %ld bytes in growtrail ]\n",64*1024L);
|
||||
Abort("");
|
||||
Error(SYSTEM_ERROR, TermNil, "YAP failed to reserve %ld bytes in growtrail", 64*1024L);
|
||||
}
|
||||
/* just in case, make sure the OS keeps the signal handler. */
|
||||
/* my_signal_info(SIGSEGV, HandleSIGSEGV); */
|
||||
@ -1270,7 +1269,7 @@ ReceiveSignal (int s)
|
||||
#ifndef MPW
|
||||
case SIGFPE:
|
||||
my_signal (SIGFPE, HandleMatherr);
|
||||
Abort ("[ Fatal error: floating point exception ]");
|
||||
Error (SYSTEM_ERROR, TermNil, "floating point exception ]");
|
||||
break;
|
||||
#endif
|
||||
#if !defined(LIGHT) && !defined(_WIN32)
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h.m4,v 1.13 2001-12-17 18:31:11 vsc Exp $ *
|
||||
* version: $Id: Yap.h.m4,v 1.14 2001-12-18 22:01:26 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -773,7 +773,8 @@ typedef enum {
|
||||
UserMode = 2, /* Normal mode */
|
||||
CritMode = 4, /* If we are meddling with the heap */
|
||||
AbortMode = 8, /* expecting to abort */
|
||||
InterruptMode = 16 /* under an interrupt */
|
||||
InterruptMode = 16, /* under an interrupt */
|
||||
InErrorMode = 32 /* under an interrupt */
|
||||
} prolog_exec_mode;
|
||||
|
||||
extern prolog_exec_mode PrologMode;
|
||||
@ -831,7 +832,7 @@ extern int yap_argc;
|
||||
} \
|
||||
if (PrologMode & AbortMode) { \
|
||||
PrologMode &= ~AbortMode; \
|
||||
Abort(""); \
|
||||
Error(PURE_ABORT, TermNil, ""); \
|
||||
} \
|
||||
GLOBAL_LOCKS_who_locked_heap = MAX_WORKERS; \
|
||||
UNLOCK(GLOBAL_LOCKS_heap_access); \
|
||||
@ -854,7 +855,7 @@ extern int yap_argc;
|
||||
} \
|
||||
if (PrologMode & AbortMode) { \
|
||||
PrologMode &= ~AbortMode; \
|
||||
Abort(""); \
|
||||
Error(PURE_ABORT, TermNil, ""); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
Reference in New Issue
Block a user