From: Andrea Corallo Date: Wed, 13 May 2020 07:52:47 +0000 (+0100) Subject: Sanity check on lambdas fixups X-Git-Tag: emacs-28.0.90~2727^2~639 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e351a12216519d3ed09892752ce0b137f6672986;p=emacs.git 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. --- 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;