~ chicken-core (chicken-5) f1912ad2ba948df71dc99f6088347dfaae6b8e99


commit f1912ad2ba948df71dc99f6088347dfaae6b8e99
Author:     Mario Domenech Goulart <mario@parenteses.org>
AuthorDate: Sat Nov 11 20:00:44 2023 +0100
Commit:     felix <felix@call-with-current-continuation.org>
CommitDate: Sun Nov 12 13:23:48 2023 +0100

    chicken-install: Reset egg cache when status file does not exist
    
    If for whatever reason the status file doesn't exist, reset the cache
    of the egg to prevent the object files in there from being reused.
    
    This might happen when a CHICKEN older than 2f6a7221 caches an egg,
    and we try to install that egg with a CHICKEN newer than 2f6a7221.
    The older CHICKEN had installed a `STATUS' file, and the newer CHICKEN
    will look for a `_STATUS' file, which won't exist.  If chicken-install
    ignores the existence of the status file and reuses object files, we
    might mix incompatible binaries produced by different versions of
    CHICKEN and C compilers, leading to errors like
    
      [panic] invalid encoded literal format - execution terminated
    
    Signed-off-by: felix <felix@call-with-current-continuation.org>

diff --git a/chicken-install.scm b/chicken-install.scm
index d0d9f8aa..56c741db 100644
--- a/chicken-install.scm
+++ b/chicken-install.scm
@@ -425,7 +425,15 @@
         (delete-directory cached #t))
       (create-directory cached #t)
       (fetch-egg-sources name version cached lax))
-    (cond ((or (not (probe-dir cached))
+    (cond ((and (probe-dir cached)
+                (not (file-exists? status)))
+           ;; If for whatever reason the status file doesn't exist
+           ;; (e.g., it was renamed, as in 2f6a7221), reset the cache
+           ;; of the egg to prevent the object files in there from
+           ;; being reused.
+           (d "resetting ~a, as ~a does not exist~%" cached status)
+           (fetch #f))
+	  ((or (not (probe-dir cached))
                (not (file-exists? eggfile)))
            (d "~a not cached~%" name)
            (when cached-only (error "extension not cached" name))
Trap