1.0.24.3: sanity check address spaces
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 2 Jan 2009 12:42:08 +0000 (12:42 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 2 Jan 2009 12:42:08 +0000 (12:42 +0000)
 * Genesis to check that spaces don't overlap.

 * At startup make sure --dynamic-space-size doesn't overflow, or run
   into any space possibly on top of dynamic space. (GENCGC only.)

package-data-list.lisp-expr
src/compiler/generic/early-vm.lisp
src/compiler/generic/genesis.lisp
src/runtime/runtime.c
version.lisp-expr

index 3017d38..ef147f7 100644 (file)
@@ -2569,6 +2569,7 @@ structure representations"
                "*CONTROL-STACK-START*" "*CONTROL-STACK-END*"
                "CONTROL-STACK-POINTER-VALID-P"
                "DYNAMIC-SPACE-START" "DYNAMIC-SPACE-END"
+               #!+gencgc "MAX-DYNAMIC-SPACE-END"
                #!+c-stack-is-control-stack "ALTERNATE-SIGNAL-STACK-START"
                #!-gencgc "DYNAMIC-0-SPACE-START"
                #!-gencgc "DYNAMIC-0-SPACE-END"
index 57c2d9d..2a39fc3 100644 (file)
   (min #x1fffffffffffff most-positive-fixnum))
 (def!constant most-negative-exactly-double-float-fixnum
   (max #x-1fffffffffffff most-negative-fixnum))
+
+;;;; Point where continuous area starting at dynamic-space-start bumps into
+;;;; next space.
+#!+gencgc
+(def!constant max-dynamic-space-end
+    (let ((stop (1- (ash 1 n-word-bits)))
+          (start dynamic-space-start))
+      (dolist (other-start (list read-only-space-start static-space-start linkage-table-space-start))
+        (when (< start other-start)
+          (setf stop (min stop other-start))))
+      stop))
index f1f1c96..51ccf01 100644 (file)
@@ -2594,6 +2594,30 @@ core and return a descriptor to it."
     (do-cold-fixup code-object offset value kind)
     code-object))
 \f
+;;;; sanity checking space layouts
+
+(defun check-spaces ()
+  ;;; Co-opt type machinery to check for intersections...
+  (let (types)
+    (flet ((check (start end space)
+             (unless (< start end)
+               (error "Bogus space: ~A" space))
+             (let ((type (specifier-type `(integer ,start ,end))))
+               (dolist (other types)
+                 (unless (eq *empty-type* (type-intersection (cdr other) type))
+                   (error "Space overlap: ~A with ~A" space (car other))))
+               (push (cons space type) types))))
+      (check sb!vm:read-only-space-start sb!vm:read-only-space-end :read-only)
+      (check sb!vm:static-space-start sb!vm:static-space-end :static)
+      #!+gencgc
+      (check sb!vm:dynamic-space-start sb!vm:dynamic-space-end :dynamic)
+      #!-gencgc
+      (progn
+        (check sb!vm:dynamic-0-space-start sb!vm:dynamic-0-space-end :dynamic-0)
+        (check sb!vm:dynamic-1-space-start sb!vm:dynamic-1-space-end :dynamic-1))
+      #!+linkage-table
+      (check sb!vm:linkage-table-space-start sb!vm:linkage-table-space-end :linkage-table))))
+\f
 ;;;; emitting C header file
 
 (defun tailwise-equal (string tail)
@@ -3145,6 +3169,8 @@ initially undefined function references:~2%")
     (do-all-symbols (sym)
       (remprop sym 'cold-intern-info))
 
+    (check-spaces)
+
     (let* ((*foreign-symbol-placeholder-value* (if core-file-name nil 0))
            (*load-time-value-counter* 0)
            (*cold-fdefn-objects* (make-hash-table :test 'equal))
index 2d0e68d..6c2df40 100644 (file)
@@ -302,6 +302,11 @@ main(int argc, char *argv[], char *envp[])
                 dynamic_space_size = strtol(argv[argi++], 0, 0) << 20;
                 if (errno)
                     lose("argument to --dynamic-space-size is not a number");
+#               ifdef MAX_DYNAMIC_SPACE_END
+                if (!((DYNAMIC_SPACE_START < DYNAMIC_SPACE_START+dynamic_space_size) &&
+                      (DYNAMIC_SPACE_START+dynamic_space_size <= MAX_DYNAMIC_SPACE_END)))
+                    lose("specified --dynamic-space-size too large");
+#               endif
             } else if (0 == strcmp(arg, "--control-stack-size")) {
                 ++argi;
                 if (argi >= argc)
@@ -309,7 +314,7 @@ main(int argc, char *argv[], char *envp[])
                 errno = 0;
                 thread_control_stack_size = strtol(argv[argi++], 0, 0) << 20;
                 if (errno)
-                    lose("argument to --dynamic-space-size is not a number");
+                    lose("argument to --control-stack-size is not a number");
             } else if (0 == strcmp(arg, "--debug-environment")) {
                 int n = 0;
                 printf("; Commandline arguments:\n");
index 1ee247d..781f17b 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.24.2"
+"1.0.24.3"