From d970a7aa8be2cfdc15c340382b99ef9db4428df3 Mon Sep 17 00:00:00 2001 From: William Harold Newman Date: Wed, 21 Sep 2005 17:21:29 +0000 Subject: [PATCH] 0.9.4.84: suppressed stuff for old Linux systems (like one of mine) which don't have it (Assuming that I didn't make some weird clerical error, the changes are smaller than they look; I added some extra braces and let emacs regularize the indentation in hopes that it would make it less likely for me to mess up the nesting of if() and #if.) --- src/runtime/linux-os.c | 86 +++++++++++++++++++++++++++++++----------------- version.lisp-expr | 2 +- 2 files changed, 57 insertions(+), 31 deletions(-) diff --git a/src/runtime/linux-os.c b/src/runtime/linux-os.c index 6724d15..6c77f5a 100644 --- a/src/runtime/linux-os.c +++ b/src/runtime/linux-os.c @@ -53,6 +53,17 @@ #endif #ifdef LISP_FEATURE_LINUX +/* Linux "man personality" on Debian 3.1 doesn't say what Linux + * version introduced support for #include , but + * judging from jesnell's code for sbcl-0.9.4, 'twas Linux 2.6. */ +#define PERSONALITY_SUPPORTED_AT_COMPILE_TIME \ + (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) +#else +/* Linux "man personality" on Debian 3.1 says that + * stuff is Linux-only. */ +#define PERSONALITY_SUPPORTED_AT_COMPILE_TIME 0 +#endif +#if PERSONALITY_SUPPORTED_AT_COMPILE_TIME #include #endif @@ -140,50 +151,65 @@ os_init(char *argv[], char *envp[]) #ifdef LISP_FEATURE_SB_THREAD futex_wait(futex,-1); if(errno==ENOSYS) { - lose("This version of sbcl is compiled with threading support, but your kernel is too old to support this.\n\ -Please use a more recent kernel or a version of sbcl without threading support.\n"); + lose("This version of SBCL is compiled with threading support, but your kernel is too old to support this.\n\ +Please use a more recent kernel or a version of SBCL without threading support.\n"); } if(! isnptl()) { - lose("This version of sbcl only works correctly with the NPTL threading library. Please use a newer glibc, older sbcl or stop using LD_ASSUME_KERNEL"); + lose("This version of SBCL only works correctly with the NPTL threading library. Please use a newer glibc, use an older SBCL, or stop using LD_ASSUME_KERNEL"); } #endif os_vm_page_size = getpagesize(); +#ifdef LISP_FEATURE_LINUX /* KLUDGE: Disable memory randomization on new Linux kernels * by setting a personality flag and re-executing. (We need * to re-execute, since the memory maps that can conflict with * the SBCL spaces have already been done at this point). */ -#if defined(LISP_FEATURE_X86) if ((major_version == 2 && minor_version >= 6) - || major_version >= 3) - { - long pers = personality(-1); - /* 0x40000 aka. ADDR_NO_RANDOMIZE */ - if (!(pers & 0x40000)) { - if (personality(pers | 0x40000) != -1) { - /* Use /proc/self/exe instead of trying to figure out the - * executable path from PATH and argv[0], since that's - * unreliable. We follow the symlink instead of executing - * the file directly to avoid top from displaying the - * name of the process as "exe". - */ - char runtime[PATH_MAX+1]; - int i = readlink("/proc/self/exe", runtime, PATH_MAX); - if (i != -1) { - runtime[i] = '\0'; - execve(runtime, argv, envp); - } - } - /* Either changing the personality or execve() failed. Either - * way we might as well continue, and hope that the random - * memory maps are ok this time around. - */ - fprintf(stderr, "WARNING: Couldn't re-execute SBCL with the proper personality flags (maybe /proc isn't mounted?). Trying to continue anyway.\n"); - } - } + || major_version >= 3) { /* i.e., if running on Linux which is new + * enough to have */ +#if PERSONALITY_SUPPORTED_AT_COMPILE_TIME + { + long pers = personality(-1); + /* 0x40000 aka. ADDR_NO_RANDOMIZE */ + if (!(pers & 0x40000)) { + if (personality(pers | 0x40000) != -1) { + /* Use /proc/self/exe instead of trying to figure out + * the executable path from PATH and argv[0], since + * that's unreliable. We follow the symlink instead of + * executing the file directly in order to prevent top + * from displaying the name of the process as "exe". */ + char runtime[PATH_MAX+1]; + int i = readlink("/proc/self/exe", runtime, PATH_MAX); + if (i != -1) { + runtime[i] = '\0'; + execve(runtime, argv, envp); + } + } + /* Either changing the personality or execve() failed. Either + * way we might as well continue, and hope that the random + * memory maps are ok this time around. + */ + fprintf(stderr, "WARNING: Couldn't re-execute SBCL with the proper personality flags (maybe /proc isn't mounted?). Trying to continue anyway.\n"); + } + } +#else + /* KLUDGE: This doesn't seem like a particularly clever thing + * to do, but I can't think of anything better at the moment. + * One rigorously-correct-seeming possibility would be to have + * personality() stuff be suppressed only at the explicit + * request of the builder (in customize-target-features.lisp), + * and then simply continue here without error, on the theory + * that the builder knew what he was doing. But even to me + * that seems like a lot of trouble to put the user to in the + * common case when he's building on the same system he's + * running on. -- WHN */ + lose("This SBCL executable was built on some system too old to have , and running it on this newer system which has is unsupported. Consider rebuilding SBCL from source on the new system."); #endif + } } +#endif #ifdef LISP_FEATURE_ALPHA diff --git a/version.lisp-expr b/version.lisp-expr index ae1bd0f..46f68ff 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.4.83" +"0.9.4.84" -- 1.7.10.4