author | Camm Maguire <camm@debian.org> | 2014年08月18日 21:13:58 +0000 |
---|---|---|
committer | Camm Maguire <camm@debian.org> | 2014年08月18日 21:13:58 +0000 |
commit | 9a413d1ece0aaf38bcbf0398be99f441bed667b6 (patch) | |
tree | b4fa72b7f022f67160d0a97b3e5439f873849ce4 | |
parent | bb7c9c143856c8452d878dcccd47d881a5b89fff (diff) | |
download | gcl-9a413d1ece0aaf38bcbf0398be99f441bed667b6.tar.gz |
-rw-r--r-- | gcl/h/protoize.h | 2 | ||||
-rw-r--r-- | gcl/o/alloc.c | 3 | ||||
-rwxr-xr-x | gcl/o/sgbc.c | 25 |
diff --git a/gcl/h/protoize.h b/gcl/h/protoize.h index 3d8ff1f44..f1a50f655 100644 --- a/gcl/h/protoize.h +++ b/gcl/h/protoize.h @@ -243,7 +243,7 @@ typedef void (*funcvoid)(void); #ifndef __MINGW32__ /* #include <signal.h> */ #endif -/* sgbc.c:1246:OF */ extern void memory_protect (int on); /* (on) int on; */ +/* sgbc.c:1246:OF */ extern int memory_protect (int on); /* (on) int on; */ /* sgbc.c:1306:OF */ extern void perm_writable (char *p, long n); /* (p, n) char *p; int n; */ /* sgbc.c:1321:OF */ extern void system_error (void); /* () */ /* gbc.c:1357:OF */ extern void gcl_init_GBC (void); /* () */ diff --git a/gcl/o/alloc.c b/gcl/o/alloc.c index 58a266126..39927c06f 100644 --- a/gcl/o/alloc.c +++ b/gcl/o/alloc.c @@ -1089,7 +1089,8 @@ gcl_init_alloc(void *cs_start) { massert(getpagesize()<=PAGESIZE); memprotect_test_reset(); if (sgc_enabled) - memory_protect(1); + if (memory_protect(1)) + sgc_quit(); #endif diff --git a/gcl/o/sgbc.c b/gcl/o/sgbc.c index 042177def..2f37cad6c 100755 --- a/gcl/o/sgbc.c +++ b/gcl/o/sgbc.c @@ -10,10 +10,6 @@ static void sgc_mark_object1(object); -static void -sgc_mprotect(long, long, int); - - #ifdef BSD /* ulong may have been defined in mp.h but the define is no longer needed */ #undef ulong @@ -1332,8 +1328,9 @@ sgc_start(void) { and modified the tm_table; Turn memory protection on for the pages which are writable. */ - memory_protect(1); sgc_enabled=1; + if (memory_protect(1)) + sgc_quit(); if (sSAnotify_gbcA->s.s_dbind != Cnil) { printf("[SGC on]"); fflush(stdout); @@ -1521,7 +1518,7 @@ memprotect_handler(int sig, long code, void *scp, char *addr) { } -static void +static int sgc_mprotect(long pbeg, long n, int writable) { /* CHECK_RANGE(pbeg,n); */ #ifdef DEBUG_MPROTECT @@ -1532,13 +1529,18 @@ sgc_mprotect(long pbeg, long n, int writable) { fflush(stdout); #endif if(mprotect(pagetoinfo(pbeg),n*PAGESIZE, - (writable & SGC_WRITABLE ? PROT_READ_WRITE_EXEC : PROT_READ_EXEC))) - FEerror("Couldn't protect",0); + (writable & SGC_WRITABLE ? PROT_READ_WRITE_EXEC : PROT_READ_EXEC))) { + perror("mprotect failure, sgc disabled"); + return -1; + } + + return 0; + } -void +int memory_protect(int on) { unsigned long i,beg,end= page(core_end); @@ -1563,12 +1565,15 @@ memory_protect(int on) { if (writable==IS_WRITABLE(i) && i<=end) continue; - sgc_mprotect(beg,i-beg,writable); + if (sgc_mprotect(beg,i-beg,writable)) + return -1; writable=1-writable; beg=i; } + return 0; + } static void |