Subject: bug#45117: 28.0.50; process-send-string mysteriously exiting non-locally when called from timer

From: Eli Zaretskii <[email-masked]>
Date: Tue, 08 Dec 2020 19:01:18 +0200

> From: João Távora <[email-masked]>
> Cc: [email-masked]
> Date: Tue, 08 Dec 2020 15:56:49 +0000
> 
> > Can you elaborate on the evidence you found of this non-local exit?
> 
> It was evidenced by M-x trace-function process-send-string RET and also
> by substituting the snippet I posted earlier with:
> 
>     (unwind-protect
>        (progn
>          (sly-send `(:emacs-rex ,form ,package ,thread ,id ,@extra-options))
>          (setq send-success t))
>      (if send-success
>          (push (cons id continuation) (sly-rex-continuations))
>        (sly-message
>         "[issue#385] likely `process-send-string' exited non-locally from timer.")
>        (sly-log-event `(:issue-385-sly-send-fishiness :id ,id
>                                                       :form
>                                                       ,form )
>                       sly-dispatching-connection)))
> 
> Once in a while, the else branch of the if triggered.
> 
> Anyway, here's an observation:
> 
>     1 -> (process-send-string #<process sly-1> "00044d(:emacs-rex
>     (slynk:autodoc (quote (\"defpackage\" \":slynk\" (\":use\" \":cl\"
>     \":slynk-backend\" \":slynk-match\" \":slynk-rpc\") (\":export\"
>     \"#:startup-multiprocessing\" \"#:start-server\" \"#:create-server\"
>     \"#:stop-server\" \"#:restart-server\" \"#:ed-in-emacs\"
>     \"#:inspect-in-emacs\" \"#:print-indentation-lossage\"
>     \"#:invoke-sly-debugger\" \"#:slynk-debugger-hook\" \"#:emacs-inspect\"
>     \"#:authenticate-client\" \"#:*loopback-interface*\"
>     \"#:*buffer-readtable*\" \"#:process-requests\") (\":export\"
>     \"#:*communication-style*\" \"#:*dont-close*\"
>     \"#:*fasl-pathname-function*\" \"#:*log-events*\" \"#:*log-output*\"
>     \"#:*configure-emacs-indentation*\" \"#:*readtable-alist*\"
>     \"#:*global-debugger*\" \"#:*sly-db-quit-restart*\"
>     \"#:*backtrace-printer-bindings*\"
>     \"#:*default-worker-thread-bindings*\"
>     \"#:*macroexpand-printer-bindings*\" \"#:*slynk-pprint-bindings*\"
>     \"#:*string-elision-length*\" \"#:*inspector-verbose*\"
>     \"#:*require-module*\" \"#:*eval-for-emacs-wrappers*\"
>     \"#:*debugger-extra-options*\" \"#:*globally-redirect-io*\"
>     \"#:*use-dedicated-output-stream*\" \"#:*dedicated-output-stream-port*\"
>     slynk::%cursor-marker%))) :print-right-margin 80) \":slynk\" t 100) ") 1
>     <- process-send-string: !non-local\ exit!

Then my suggestion is to run this under GDB with a breakpoint on the
few places we call sys_longjmp, and when it breaks, show the C and
Lisp backtrace from there.