all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Pip Cet <pipcet@protonmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: eller.helmut@gmail.com, gerd.moellmann@gmail.com,
	yantar92@posteo.net, emacs-devel@gnu.org
Subject: Re: MPS: a random backtrace while toying with gdb
Date: Tue, 02 Jul 2024 14:24:33 +0000	[thread overview]
Message-ID: <toQN75FiHqu4zzAjbK9x05oVUHinYzL_yWiB67YwQ_iupwYisPJfWm9E2NvP8j9sFrdJqBw7hpTkthOjS9ZoWWUrTzPxcTAZxV2Ij0JHvTU=@protonmail.com> (raw)
In-Reply-To: <86h6d8c52h.fsf@gnu.org>

On Tuesday, July 2nd, 2024 at 13:10, Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Tue, 02 Jul 2024 07:55:26 +0000
> 
> > From: Pip Cet pipcet@protonmail.com
> > Cc: eller.helmut@gmail.com, gerd.moellmann@gmail.com, yantar92@posteo.net, emacs-devel@gnu.org
> > 
> > > Which is why I suggested to block the signals before calling MPS and
> > > unblock them immediately when we return from an MPS call. All of
> > > these calls are in igc.c, so the job of adding these blocks, while
> > > mundane and boring, is not impossible.
> > 
> > And it adds two syscalls to what should be a very fast operation. I'm not convinced it's necessary.
> 
> We should time these syscalls if we are afraid they could slow us
> down.

Agreed.

> > > That's not the problem, AFAIU. The problem is that a signal handler
> > > which accesses Lisp data or the state of the Lisp machine could
> > > trigger an MPS call, which will try taking the arena lock, and that
> > > cannot be nested, by MPS design. And our handlers do access the Lisp
> > > machine, albeit cautiously and as little as necessary. So when the
> > > signal happens in the middle of an MPS call which already took the
> > > arena lock, we cannot safely access our data.
> > 
> > I've tried quite hard to make this happen, but I didn't manage it. It seems that whenever MPS puts up a protection barrier for existing allocated memory, the arena lock has already been released. As signal handlers cannot allocate memory directly, there's no deadlock, either.
> > 
> > I don't understand MPS as well as you apparently do, so could you help me and tell where to put a kill(getpid(), SIGWHATEVER) with an appropriate signal handler which will cause a crash (without, in the signal handler, allocating memory)?
> 
> I thought using the profiler would trigger these easily enough? I
> think someone (Helmut?) posted a simple recipe for reproducing that
> some time ago?

Those were all signals interrupting MPS's SIGSEGV handler. You were talking about signals interrupting MPS code that runs outside of a signal handler, weren't you?

> Also, there was a recipe with SIGCHLD not long ago (you'd need to undo
> Helmut's fixes for that, I believe, to be able to reproduce that).

Same thing.

> > I'm seriously tempted to suggest that until we can produce such a crash, we can work on the assumption that blocking signals while handling SIGSEGV is enough, but, again, I don't fully understand MPS and its complicated locking scheme.
> 
> I agree that having a reproduction recipe is a necessary condition for
> trying to fix this.

Excellent.

> > To expand a little on what I'm doing:
> > 
> > * install a handler for SIGUSR2 which dereferences a pointer stored in a global variable (and remove the old SIGUSR2 handler)
> > * modify MPS's locking functions to kill(getpid(), SIGUSR2) right after acquiring the lock
> > * in gdb, wait for a SIGSEGV to find a protected address/segment. Store that in the pointer variable.
> > * there should now be a crash when the SIGUSR2 handler runs and memory protection for the pointer is in effect
> > * no crashes observed so far.
> 
> Why not simply bind the sigusr2 event to some function (see the node
> "Misc Events" in the ELisp manual for how), and then use "kill -USR2"
> outside of Emacs? IOW, I guess I don't understand why you'd need all
> that complexity just to reproduce the crashes.

Because I wanted to be sure to hit the tiny window while a global lock was taken.

Pip



  reply	other threads:[~2024-07-02 14:24 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-29 19:12 MPS: a random backtrace while toying with gdb Ihor Radchenko
2024-06-29 19:19 ` Pip Cet
2024-06-29 21:46   ` Gerd Möllmann
2024-06-30  4:55     ` Eli Zaretskii
2024-06-30  5:33       ` Gerd Möllmann
2024-06-30  6:16         ` Eli Zaretskii
2024-06-30  6:43           ` Gerd Möllmann
2024-06-30  8:52             ` Eli Zaretskii
2024-06-30  9:43               ` Gerd Möllmann
2024-06-30 10:05                 ` Eli Zaretskii
2024-06-30 11:20                   ` Gerd Möllmann
2024-06-30 12:16                     ` Eli Zaretskii
2024-06-30 12:43                       ` Gerd Möllmann
2024-06-30  9:36     ` Helmut Eller
2024-06-30 10:00       ` Eli Zaretskii
2024-06-30 10:24         ` Helmut Eller
2024-06-30 10:43           ` Eli Zaretskii
2024-06-30 18:42             ` Helmut Eller
2024-06-30 18:59               ` Gerd Möllmann
2024-06-30 19:25               ` Pip Cet
2024-06-30 19:49                 ` Ihor Radchenko
2024-06-30 20:09                 ` Eli Zaretskii
2024-06-30 20:32                   ` Pip Cet
2024-07-01 11:07                     ` Eli Zaretskii
2024-07-01 17:27                       ` Pip Cet
2024-07-01 17:42                         ` Ihor Radchenko
2024-07-01 18:08                         ` Eli Zaretskii
2024-07-02  7:55                           ` Pip Cet
2024-07-02 13:10                             ` Eli Zaretskii
2024-07-02 14:24                               ` Pip Cet [this message]
2024-07-02 14:57                                 ` Eli Zaretskii
2024-07-02 17:06                                   ` Pip Cet
2024-07-03 11:31                                     ` Pip Cet
2024-07-03 11:50                                       ` Eli Zaretskii
2024-07-03 14:35                                         ` Pip Cet
2024-07-03 15:41                                           ` Eli Zaretskii
2024-07-01  2:33                 ` Eli Zaretskii
2024-07-01  6:05                 ` Helmut Eller
2024-06-30 19:58               ` Eli Zaretskii
2024-06-30 21:08                 ` Ihor Radchenko
2024-07-01  2:35                   ` Eli Zaretskii
2024-07-01 11:13                   ` Eli Zaretskii
2024-07-01 11:47                     ` Ihor Radchenko
2024-07-01 12:33                       ` Eli Zaretskii
2024-07-01 17:17                         ` Ihor Radchenko
2024-07-01 17:44                           ` Eli Zaretskii
2024-07-01 18:01                             ` Ihor Radchenko
2024-07-01 18:16                               ` Eli Zaretskii
2024-07-01 18:24                                 ` Ihor Radchenko
2024-07-01 18:31                                   ` Eli Zaretskii
2024-07-01 18:51                                     ` Ihor Radchenko
2024-07-01 19:05                                       ` Eli Zaretskii
2024-07-01 19:34                                       ` Gerd Möllmann
2024-07-01 20:00                                         ` Ihor Radchenko
2024-07-02  4:33                                           ` Gerd Möllmann
2024-07-02  7:05                                             ` Ihor Radchenko
2024-07-02  7:06                                               ` Gerd Möllmann
2024-07-01 18:19                               ` Gerd Möllmann
2024-07-01 18:23                                 ` Eli Zaretskii
2024-06-30 11:07           ` Gerd Möllmann
2024-06-30 11:06         ` Gerd Möllmann
2024-06-30 11:05       ` Gerd Möllmann
2024-06-30  9:59     ` Pip Cet
2024-06-30 10:09       ` Eli Zaretskii
2024-06-30 10:16         ` Pip Cet
2024-06-30 10:34           ` Eli Zaretskii
2024-06-30 13:06             ` Pip Cet
2024-06-30 11:10       ` Gerd Möllmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='toQN75FiHqu4zzAjbK9x05oVUHinYzL_yWiB67YwQ_iupwYisPJfWm9E2NvP8j9sFrdJqBw7hpTkthOjS9ZoWWUrTzPxcTAZxV2Ij0JHvTU=@protonmail.com' \
    --to=pipcet@protonmail.com \
    --cc=eliz@gnu.org \
    --cc=eller.helmut@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=gerd.moellmann@gmail.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.