From d47b2f66bdb7abc9de99658e8dbdd1c7c108881e Mon Sep 17 00:00:00 2001 From: Stas Boukarev Date: Thu, 10 May 2012 02:47:03 +0400 Subject: [PATCH] Fix --dynamic-space-size 1GB on x86. Use unsigned longs instead of signed longs for handling --dynamic-space-size, on x86 it can easily be exhausted. --- NEWS | 5 +++-- src/runtime/runtime.c | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 71ddcd1..2c3b5f6 100644 --- a/NEWS +++ b/NEWS @@ -123,8 +123,8 @@ changes in sbcl-1.0.55 relative to sbcl-1.0.54: * optimization: the compiler no longer refuses to coerce large fixnums to single floats inline, except on x86 where this limitation is still necessary. - * optimization: truncation operations with constant divisor arguments - 1 and -1 are optimized away. + * optimization: truncation operations on integers with constant divisor + arguments 1 and -1 are optimized away. * bug fix: deadlock detection could report the same deadlock twice, for two different threads. Now a single deadlock is reported exactly once. * bug fix: interval-arithmetic division during type derivation did not @@ -169,6 +169,7 @@ changes in sbcl-1.0.55 relative to sbcl-1.0.54: forms of MAKE-ARRAY with dynamic-extent. (lp#902351) * bug fix: some of the compile-time side-effects of DEFCLASS were not caught by package locks. + * bug fix: Proper handling of --dynamic-space-size option on 32 bit platforms. changes in sbcl-1.0.54 relative to sbcl-1.0.53: * minor incompatible changes: diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index d2cb732..f66a7e5 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -292,11 +292,13 @@ search_for_executable(const char *argv0) } #endif /* LISP_FEATURE_WIN32 */ -long parse_size_arg(char *arg, char *arg_name) +unsigned long parse_size_arg(char *arg, char *arg_name) { char *tail, *power_name; - long power, res; - res = strtol(arg, &tail, 0); + unsigned long power, res; + + res = strtoul(arg, &tail, 0); + if (arg == tail) { lose("%s argument is not a number: %s", arg_name, arg); } else if (tail[0]) { @@ -325,7 +327,7 @@ long parse_size_arg(char *arg, char *arg_name) free(power_name); } if ((res <= 0) || - (res >= (LONG_MAX >> power))) { + (res > (ULONG_MAX >> power))) { lose("%s argument is out of range: %s", arg_name, arg); } res <<= power; @@ -449,7 +451,7 @@ main(int argc, char *argv[], char *envp[]) DYNAMIC_SPACE_START+dynamic_space_size) && (DYNAMIC_SPACE_START+dynamic_space_size <= MAX_DYNAMIC_SPACE_END))) - lose("--dynamic-space-size argument %s is too large, max %ldMiB", + lose("--dynamic-space-size argument %s is too large, max %lu", argv[argi-1], MAX_DYNAMIC_SPACE_END-DYNAMIC_SPACE_START); # endif } else if (0 == strcmp(arg, "--control-stack-size")) { -- 1.7.10.4