bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#45117: 28.0.50; process-send-string mysteriously exiting non-locally


From: Eli Zaretskii
Subject: bug#45117: 28.0.50; process-send-string mysteriously exiting non-locally when called from timer
Date: Wed, 09 Dec 2020 17:33:35 +0200

> From: João Távora <joaotavora@gmail.com>
> Cc: 45117@debbugs.gnu.org
> Date: Wed, 09 Dec 2020 11:24:47 +0000
> 
> [ We've been CC-ing bug-gnu-emacs@gnu.org for a while.  My fault, the
> typical CC blunder.  Wonder how debbugs was dealing with that so
> gracefully tho. ]

It should deal with this just fine, as long as you keep the same
Subject line.

> If I set breakpoints at _all_ places where we call sys_longjmp(), I risk
> tearing down my X, which I did a couple of times.
> 
> So I skip those "dangerous" breakpoints.  I'm guessing one of the
> interesting loci to break is unwind_to_catch in eval.c.  Of course that
> gets called every dang time a signal is thrown, so it's hard for me to
> catch the precise situation, even if I set up nicely and then call M-x
> redraw-display, and only then enable the breakpoint.

AFAICT, the only relevant call to sys_longjmp is in eval.c.  That is,
if we think Emacs signals an error or otherwise throws to top-level.

> It breaks near immediately, and the `bt` output I get is always from
> some other function that expectedly signalled an error as part of its
> normal control flow.

One simple method of dealing with that is to make GDB continue
immediately after hitting the breakpoint:

  break eval.c:NNNN
  commands
  > bt
  > continue
  > end

(the ">" prompt is printed by GDB).  Then you will have a lot of
backtraces, but only the last one will be relevant.  This simple
method has a disadvantage that it slows down Emacs, and also produces
a lot of possibly uninteresting stuff.

> 1. I have to find a way to set the unwind_to_catch() breakpoint
>    conditional on some Elisp/near-elisp context, in this case something
>    inside the Elisp function sly-net-send() or Fprocess_send_string.
> 
>    Do you think setting a silly global in Fprocess_send_string() and
>    then checking that as the breakpoint condition would be a good idea?
>    Where would I reset the flag?  Is there some C-version of
>    "unwind-protect"?

The C version of unwind-protect is record_unwind_protect.

But I think it will be easier to use an existing variable that is
usually not touched.  For example, you could piggy-back
bidi-inhibit-bpa, which is normally nil.  On the C level, this is a
bool variable bidi_inhibit_bpa, which is normally zero.  So, you could
wrap the problematic Lisp fragment with

  (let ((bidi-inhibit-bpa t))
    ....
    )

and then make the breakpoint conditional on that:

  break eval.c:NNNN if bidi_inhibit_bpa != 0

The advantage of this is that when the let-form unwinds, the variable
will be automatically reset (again, if we believe the theory of
signal/throw that cause the non-local exit).

HTH





reply via email to

[Prev in Thread] Current Thread [Next in Thread]