gcl.git - GNU Common Lisp

index : gcl.git
GNU Common Lisp
summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamm Maguire <camm@debian.org>2014年08月18日 21:13:58 +0000
committerCamm Maguire <camm@debian.org>2014年08月18日 21:13:58 +0000
commit9a413d1ece0aaf38bcbf0398be99f441bed667b6 (patch)
treeb4fa72b7f022f67160d0a97b3e5439f873849ce4
parentbb7c9c143856c8452d878dcccd47d881a5b89fff (diff)
downloadgcl-9a413d1ece0aaf38bcbf0398be99f441bed667b6.tar.gz
abort sgc on mprotect failure
Diffstat
-rw-r--r--gcl/h/protoize.h 2
-rw-r--r--gcl/o/alloc.c 3
-rwxr-xr-xgcl/o/sgbc.c 25
3 files changed, 18 insertions, 12 deletions
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
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月07日 23:59:30 +0000

AltStyle によって変換されたページ (->オリジナル) /