Subject: bug#37331: 27.0.50; segfault when starting from pdump and using dbus

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 12 Oct 2021 13:02:10 +0200

Eli Zaretskii <[email-masked]> writes:

> We don't yet have good support for re-dumping Emacs, so these
> questions don't have good "canonical" answers.  The infrastructure is
> not there.

Right.

To fix the original segfault, Paul added

  /* Initialize internal objects.  */
  pdumper_do_now_and_after_load (syms_of_dbusbind_for_pdumper);

(which just sets xd_registered_buses to Qnil).  Would adding a similar
thing, basically `pdumper_do_after_load', be the direction we want to go
in here?

I'm thinking basically making systems that put logic into the load
logic, like dbus is doing:

(when (featurep 'dbusbind)
  (dbus-ignore-errors
    (dbus-init-bus :system))
  (dbus-ignore-errors
    (dbus-init-bus :session)))

Rewriting that to

(eval-when-load-and-startup
  (when (featurep 'dbusbind)
    (dbus-ignore-errors
      (dbus-init-bus :system))
    (dbus-ignore-errors
      (dbus-init-bus :session))))

that would make pdump eval these forms after loading the dump file?

But it strikes me that in the dbus case, we can just avoid all this by
having a `dbus-init' function that would initialise the dbus system
unless it's already initialised, and make all the dbus interface
functions call it as the first thing...  Oh, no, we don't want to do
that, because dbus wants to start listening to the bus immediately after
Emacs starts up, so that messages are queued when code finally gets
around to querying the dbus.el functions.

OK, I think something like the `eval-when-load-and-startup' thing would
be the right thing here, then.  I'll take a stab at implementing it.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no