Subject: Re: bug#75632: 31.0.50; igc: Crash report

From: Eli Zaretskii <[email-masked]>
Date: Sun, 19 Jan 2025 07:39:34 +0200

> Date: Sat, 18 Jan 2025 20:40:47 +0000
> From: Pip Cet <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> "Eli Zaretskii" <[email-masked]> writes:
> 
> > But if we use !initialized, the code which installs the variable
> > watcher will not run in the dumped Emacs, right?
> 
> Correct.  Variable watchers are symbol properties, and symbol properties
> are restored from the dump, so there is no need to add them again.

Then why do we need to do this in C and not in Lisp?  Can't we set up
the watcher as part of some preloaded Lisp file?

> >> >> IIRC, there are some loops that test Vinhibit_quit or Vquit_flag
> >> >> directly (or use QUITP); we wouldn't be able to break out of one of
> >> >> those if we only set Vinhibit_quit from what's currently
> >> >> store_user_signal_events, would we?
> >> >
> >> > Sorry, I don't follow.  Why does it matter whether we set those
> >> > variables from a signal handler or in gobble_input?
> >>
> >> We might never reach gobble_input if the variable isn't set in the
> >> signal handler: some loops check QUITP (etc.), and if there's a bug in
> >> them and Vinhibit_quit is set, the loop might never call maybe_quit.
> >
> > Then how about setting Vquit_flag and resetting Vinhibit_quit in the
> > handler, but leaving the check whether we should call the debugger to
> > gobble_input?
> 
> 1. We can't do that unconditionally.  An ordinary SIGUSR2 should not
> cause a quit, only a special event should.  So we need to check whether
> the event we received is special or not.
> 
> 2. probably_quit handles the quit flag first, then handles pending
> signals only when it is called again, by the next maybe_quit.  That
> means by the time we reach gobble_input, it's too late to call the
> debugger.  So we need to set debug_* at the same time as setting
> Vquit_flag (or rewrite probably_quit, which probably has very good
> reasons for its peculiar behavior).

OK, but could we at least make this somewhat cleaner?  Instead of
copying the name of the event aside, can we produce a C integer that
identifies the event, and store that number instead?  Accessing
integers from a signal handler should not be a problem, right?  (In
retrospect, we should have probably made debug-on-event a function,
then we could produce that number inside the function, thus avoiding
the need for watching the variable.  Maybe we should introduce the
function now and deprecate the variable?)