Add better error message for out of memory
							parent
							
								
									1f39689e76
								
							
						
					
					
						commit
						5a0c3e3d73
					
				| 
						 | 
				
			
			@ -1,5 +1,12 @@
 | 
			
		|||
#include "master.h"
 | 
			
		||||
 | 
			
		||||
void out_of_memory(void)
 | 
			
		||||
{
 | 
			
		||||
	fprintf(stderr,"Out of memory\n\n");
 | 
			
		||||
	dump_generations();
 | 
			
		||||
	exit(1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void fatal_error(char* msg, CELL tagged)
 | 
			
		||||
{
 | 
			
		||||
	fprintf(stderr,"fatal_error: %s %lx\n",msg,tagged);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ typedef enum
 | 
			
		|||
	ERROR_MEMORY,
 | 
			
		||||
} F_ERRORTYPE;
 | 
			
		||||
 | 
			
		||||
void out_of_memory(void);
 | 
			
		||||
void fatal_error(char* msg, CELL tagged);
 | 
			
		||||
void critical_error(char* msg, CELL tagged);
 | 
			
		||||
DECLARE_PRIMITIVE(die);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -174,7 +174,7 @@ F_SEGMENT *alloc_segment(CELL size)
 | 
			
		|||
		MAP_ANON | MAP_PRIVATE,-1,0);
 | 
			
		||||
 | 
			
		||||
	if(array == (char*)-1)
 | 
			
		||||
		fatal_error("Out of memory in alloc_segment",0);
 | 
			
		||||
		out_of_memory();
 | 
			
		||||
 | 
			
		||||
	if(mprotect(array,pagesize,PROT_NONE) == -1)
 | 
			
		||||
		fatal_error("Cannot protect low guard page",(CELL)array);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -171,7 +171,7 @@ F_SEGMENT *alloc_segment(CELL size)
 | 
			
		|||
 | 
			
		||||
	if((mem = (char *)VirtualAlloc(NULL, getpagesize() * 2 + size,
 | 
			
		||||
		MEM_COMMIT, PAGE_EXECUTE_READWRITE)) == 0)
 | 
			
		||||
		fatal_error("Out of memory in alloc_segment",0);
 | 
			
		||||
		out_of_memory();
 | 
			
		||||
 | 
			
		||||
	if (!VirtualProtect(mem, getpagesize(), PAGE_NOACCESS, &ignore))
 | 
			
		||||
		fatal_error("Cannot allocate low guard page", (CELL)mem);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue