From cb254941e176badff31a16a11509e1ac288ae249 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Fri, 30 Dec 2005 00:21:40 +0000 Subject: [PATCH] 0.9.8.6: Make the count of fasl header counted strings a 32-bit value also on 64-bit platforms. This ensures that a x86-64 SBCL can gracefully detect an error when trying to read a x86 fasl instead of choking on a ridiculously long counted string. --- src/code/early-fasl.lisp | 4 +++- src/code/load.lisp | 6 +++++- src/compiler/dump.lisp | 15 ++++++++++++++- version.lisp-expr | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/code/early-fasl.lisp b/src/code/early-fasl.lisp index 52a21aa..b55311d 100644 --- a/src/code/early-fasl.lisp +++ b/src/code/early-fasl.lisp @@ -76,7 +76,7 @@ ;;; versions which break binary compatibility. But it certainly should ;;; be incremented for release versions which break binary ;;; compatibility. -(def!constant +fasl-file-version+ 61) +(def!constant +fasl-file-version+ 62) ;;; (record of versions before 2003 deleted in 2003-04-26/0.pre8.107 or so) ;;; 38: (2003-01-05) changed names of internal SORT machinery ;;; 39: (2003-02-20) in 0.7.12.1 a slot was added to @@ -128,6 +128,8 @@ ;;; 60: (2005-10-24) Bumped for 0.9.6 ;;; 61: (2005-11-06) Improved source location recording added extra parameters ;;; to multiple %DEFMUMBLE functions. +;;; 62: (2005-12-30) Make the count of FASL header counted strings +;;; a 32-bit value also on 64-bit platforms. ;;; the conventional file extension for our fasl files (declaim (type simple-string *fasl-file-type*)) diff --git a/src/code/load.lisp b/src/code/load.lisp index eafe8a0..b21c7dd 100644 --- a/src/code/load.lisp +++ b/src/code/load.lisp @@ -114,6 +114,10 @@ (declare (optimize (speed 0))) (read-arg #.sb!vm:n-word-bytes)) +(defun read-unsigned-byte-32-arg () + (declare (optimize (speed 0))) + (read-arg 4)) + ;;;; the fop table @@ -305,7 +309,7 @@ ;; Read and validate version-specific compatibility stuff. (flet ((string-from-stream () - (let* ((length (read-word-arg)) + (let* ((length (read-unsigned-byte-32-arg)) (result (make-string length))) (read-string-as-bytes stream result) result))) diff --git a/src/compiler/dump.lisp b/src/compiler/dump.lisp index 24cee41..cbf4323 100644 --- a/src/compiler/dump.lisp +++ b/src/compiler/dump.lisp @@ -113,6 +113,14 @@ (dotimes (i sb!vm:n-word-bytes) (write-byte (ldb (byte 8 (* 8 i)) num) stream)))) +;; Dump a 32-bit integer. +(defun dump-unsigned-byte-32 (num fasl-output) + (declare (type sb!vm:word num)) + (declare (type fasl-output fasl-output)) + (let ((stream (fasl-output-stream fasl-output))) + (dotimes (i 4) + (write-byte (ldb (byte 8 (* 8 i)) num) stream)))) + ;;; Dump NUM to the fasl stream, represented by N bytes. This works ;;; for either signed or unsigned integers. There's no range checking ;;; -- if you don't specify enough bytes for the number to fit, this @@ -314,7 +322,12 @@ ;; Finish the header by outputting fasl file implementation, ;; version, and key *FEATURES*. (flet ((dump-counted-string (string) - (dump-word (length string) res) + ;; The count is dumped as a 32-bit unsigned-byte even on 64-bit + ;; platforms. This ensures that a x86-64 SBCL can gracefully + ;; detect an error when trying to read a x86 fasl, instead + ;; of choking on a ridiculously long counted string. + ;; -- JES, 2005-12-30 + (dump-unsigned-byte-32 (length string) res) (dotimes (i (length string)) (dump-byte (char-code (aref string i)) res)))) (dump-counted-string (symbol-name +backend-fasl-file-implementation+)) diff --git a/version.lisp-expr b/version.lisp-expr index 7038088..0d64e9f 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".) -"0.9.8.5" +"0.9.8.6" -- 1.7.10.4