From 61a14dfc6681f674ae5673856c0749fdf4af6564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Sun, 26 Apr 2026 12:25:38 +0200 Subject: [PATCH] boot: allocate first_env dynamically at startup When mprotect is used as a cheap interrupt protection, the environment must be page-aligned. For static data we'd need to use a kludge (or alignas that is not part of C99) -- the simplest thing is to use the same mechanism to allocate the first environment as the rest. That will ensure page alignment when mprotect is used (that is, when mmap allocates the environment). This was not possible before (in !341), because back then, when mmap was not used, we've been using the garbage collector to allocate th environment, but now we use the manual allocator. Fixes #828. --- CHANGELOG | 9 ++++++--- src/c/main.d | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 11eaf1b6c..89db33d65 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -29,10 +29,13 @@ * Pending changes since 26.3.27 -- bugfix: MAKE-PACKAGE destructively modified definning form conses of the - package local nicknames breaking bytecmp on such packages (#839) +- bugfix: MAKE-PACKAGE destructively modified defining form's cons cells of + the package local nicknames, breaking package literals in bytecmp (#839) -- Support for Microsoft Visual Studio compilers has been dropped +- build: support for Microsoft Visual Studio Compiler has been dropped + +- bugfix: the first environment is now always page-aligned by using the + same allocation mechanism as all subsequent envs (#828) * 26.3.27 changes since 24.5.10 diff --git a/src/c/main.d b/src/c/main.d index 7f06fe6a7..f00464c1e 100644 --- a/src/c/main.d +++ b/src/c/main.d @@ -49,7 +49,6 @@ /******************************* EXPORTS ******************************/ const char *ecl_self; -static struct cl_env_struct first_env; /************************ GLOBAL INITIALIZATION ***********************/ @@ -419,7 +418,7 @@ struct cl_core_struct cl_core = { .system_properties = ECL_NIL, - .first_env = &first_env, + .first_env = NULL, #ifdef ECL_THREADS .processes = ECL_NIL, #endif @@ -498,6 +497,9 @@ cl_boot(int argc, char **argv) setbuf(stdin, stdin_buf); setbuf(stdout, stdout_buf); #endif + + /* The first environment must be available at all times. */ + cl_core.first_env = _ecl_alloc_env(NULL); init_process(); ARGC = argc;