From e351a12216519d3ed09892752ce0b137f6672986 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Wed, 13 May 2020 08:52:47 +0100 Subject: [PATCH] Sanity check on lambdas fixups * src/pdumper.c (dump_do_dump_relocation): While fixing up lambda relocation verify placeholder coherency. * src/comp.c (syms_of_comp): Define symbol 'lambda-fixup'. * lisp/emacs-lisp/comp.el (comp-finalize-container): Leave a lambda-fixup as placeholder in the relocation as a sanity check. --- lisp/emacs-lisp/comp.el | 2 +- src/comp.c | 1 + src/pdumper.c | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index d546218940b..7de8e0177c1 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -2158,7 +2158,7 @@ These are substituted with a normal 'set' op." ;; from the corresponding m-var. collect (if (gethash obj (comp-ctxt-byte-func-to-func-h comp-ctxt)) - nil + 'lambda-fixup obj)))) (defun comp-finalize-relocs () diff --git a/src/comp.c b/src/comp.c index 3a362fd0957..d1f8fe23f0d 100644 --- a/src/comp.c +++ b/src/comp.c @@ -3891,6 +3891,7 @@ syms_of_comp (void) DEFSYM (Qfixnum, "fixnum"); DEFSYM (Qscratch, "scratch"); DEFSYM (Qlate, "late"); + DEFSYM (Qlambda_fixup, "lambda-fixup"); /* To be signaled by the compiler. */ DEFSYM (Qnative_compiler_error, "native-compiler-error"); diff --git a/src/pdumper.c b/src/pdumper.c index a1b71e87ac6..a6d12b6ea0c 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -5342,11 +5342,14 @@ dump_do_dump_relocation (const uintptr_t dump_base, if (!NILP (lambda_data_idx)) { /* This is an anonymous lambda. - We must fixup data_vec so the lambda can be referenced + We must fixup d_reloc_imp so the lambda can be referenced by code. */ Lisp_Object tem; XSETSUBR (tem, subr); - comp_u->data_imp_relocs[XFIXNUM (lambda_data_idx)] = tem; + Lisp_Object *fixup = + &(comp_u->data_imp_relocs[XFIXNUM (lambda_data_idx)]); + eassert (EQ (*fixup, Qlambda_fixup)); + *fixup = tem; Fputhash (tem, Qnil, comp_u->lambda_gc_guard); } break; -- 2.39.5