From 40b949acce1ac108b62d52d13eb2a09454f8db33 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Fri, 2 Jan 2009 12:42:08 +0000 Subject: [PATCH] 1.0.24.3: sanity check address spaces * 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 | 1 + src/compiler/generic/early-vm.lisp | 11 +++++++++++ src/compiler/generic/genesis.lisp | 26 ++++++++++++++++++++++++++ src/runtime/runtime.c | 7 ++++++- version.lisp-expr | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index 3017d38..ef147f7 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -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" diff --git a/src/compiler/generic/early-vm.lisp b/src/compiler/generic/early-vm.lisp index 57c2d9d..2a39fc3 100644 --- a/src/compiler/generic/early-vm.lisp +++ b/src/compiler/generic/early-vm.lisp @@ -54,3 +54,14 @@ (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)) diff --git a/src/compiler/generic/genesis.lisp b/src/compiler/generic/genesis.lisp index f1f1c96..51ccf01 100644 --- a/src/compiler/generic/genesis.lisp +++ b/src/compiler/generic/genesis.lisp @@ -2594,6 +2594,30 @@ core and return a descriptor to it." (do-cold-fixup code-object offset value kind) code-object)) +;;;; 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)))) + ;;;; 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)) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 2d0e68d..6c2df40 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -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"); diff --git a/version.lisp-expr b/version.lisp-expr index 1ee247d..781f17b 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -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" -- 1.7.10.4