Subject: Re: bug#57309: 29.0.50; Build error "trying to dump non fixed-up eln file"

From: Gerd Möllmann <[email-masked]>
Date: Sun, 21 Aug 2022 09:03:45 +0200

Gerd Möllmann <[email-masked]> writes:

> Gerd Möllmann <[email-masked]> writes:
> And a little bit more...
>
> The error "trying to..." comes from dump_native_comp_unit, which is
> called from dump_vectorlike, which is called from dump_object.  Dumped
> objects are recorded in a hashtable dump_context::objects_dumped.  Now
>
> (lldb) p ctx->objects_dumped
> (Lisp_Object) $294 = 0x000000010407373d (struct Lisp_Hash_Table *) $299 = 0x0000000104073738
> (lldb) expr -- hash_lookup ($299, lv, 0)
> (ptrdiff_t) $300 = 2010
> (lldb) p lv
> (Lisp_Object) $301 = 0x00000001040d0a6d (struct Lisp_Native_Comp_Unit *) $306 = 0x00000001040d0a68
>
> lv is the compilation unit in question which gives the error, and the
> dumpcontext says it is already dumped.
>
> So what now?
>
> I'd say one can encounter the same Lisp_Object more than once in a dump,
> in general.  Shouldn't there be some check somewhere in the CU code?
> Where is it?  Or is this supposed not to happen?  If so, how is it
> ensured?
>
> Questions over questions...

I think I've at least found where recognizing already dumped objects
happens.  It's here:

static dump_off
dump_object (struct dump_context *ctx, Lisp_Object object)
{
#if CHECK_STRUCTS && !defined (HASH_Lisp_Type_45F0582FD7)
# error "Lisp_Type changed. See CHECK_STRUCTS comment in config.h."
#endif
  eassert (!EQ (object, dead_object ()));

  dump_off offset = dump_recall_object (ctx, object);
  if (offset > 0)
    return offset;  /* Object already dumped.  */

dump_recall_object should have returned an offset > 0 the second time
the window.eln compilation unit was to be dumped.  (I'm almost 100% sure
that that's was is happening here because I can find it in the
objects_dumped hash table.)

Only, I don't see what is going wrong after that.  Maybe it is something
following the code above.  The flags in dump_context for example, I
don't really understand.  Or is it that dump_object_emacs_ptr returns
NULL, and something is happening then, or not happening?

Hm.