From: Pip Cet via "Emacs development discussions." <emacs-devel@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Stefan Kangas <stefankangas@gmail.com>,
gerd.moellmann@gmail.com, eller.helmut@gmail.com,
emacs-devel@gnu.org
Subject: Re: igc, macOS avoiding signals
Date: Thu, 02 Jan 2025 12:34:58 +0000 [thread overview]
Message-ID: <87seq1l7ik.fsf@protonmail.com> (raw)
In-Reply-To: <86wmfdk2lx.fsf@gnu.org>
"Eli Zaretskii" <eliz@gnu.org> writes:
>> From: Stefan Kangas <stefankangas@gmail.com>
>> Date: Thu, 2 Jan 2025 02:37:12 -0600
>> Cc: eller.helmut@gmail.com, pipcet@protonmail.com, emacs-devel@gnu.org
>>
>> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>>
>> >> Mercy: I have a lot of other Emacs-related stuff on my plate, as you
>> >> are well aware. Just keeping up with this discussion is already hard
>> >> for me. Please help me by reaching out to the MPS folks about this
>> >> issue.
>> >
>> > I think it should be something "official". Maybe Stefan Kangas could
>> > contact them, or Richard.
>>
>> I'm happy to reach out to them in official capacity, but I'm not really
>> close enough to the code to be able to usefully discuss the issue with
>> them. So I think it might be best to put some or all of you in Cc.
>>
>> Before we do anything though, are we sure that it is faster to ask them
>> to do things for us, instead of, say, just sending a patch? I'm not
>> sure how confident people are with hacking MPS, but if we are still
>> seriously entertaining the idea of a fork then maybe we should be, to
>> some extent.
>
> We don't know the answer, AFAIU. We could tell them that if they
> prefer a patch, we can send one.
I see no requirement to modify MPS, so far.
The current solution should work fine for Emacs once the special-casing
of fast symbol handlers, which Helmut is working on IIUC, is in place.
>> If we do decide to contact them, I'm afraid that I don't have sufficient
>> context to accurately describe the proposed callback. I would need to
>> ask someone to summarize the idea in sufficient detail so that we can
>> start a conversation.
>
> The problem is that evidently (at least on Posix platforms), if a
> program that uses MPS runs application code from a SIGPROF or a
> SIGALRM or a SIGCHLD signal handler can trigger a recursive access to
> the MPS arena,
Let's be specific here: it's about accessing MPS memory, not about
allocating memory. In particular, we're fully aware that thread APs
cannot be used from signal handlers if they're also used by the main
thread.
> which causes a fatal signal if that happens while MPS
> holds the arena lock.
I don't know what "fatal signal" is supposed ot mean in this case, to
the MPS folks.
If there is a memory barrier in place, the result will be a deadlock
situation, which may or may not be detected. In the first case, there
is an assertion violation, in some builds (I believe the "rash" build
will simply continue and corrupt memory). In the second case, there's a
user-visible deadlock.
If there is no memory barrier in place (for example, while the segment
in question is being scanned), but the arena lock is held, silent data
corruption will occur, because we'll read an invalid intermediate state
of the memory.
IOW, the abort() situation is the best of three possible outcomes, not
the only one we want to avoid. (I say this because I sometimes get the
impression that "make the MPS arena lock recursive" is considered as a
possible "solution"; it's not, for various reasons).
> So we want to ask for a callback when MPS is
> about to lock the arena, and another callback immediately after it
> releases the lock.
That's the first time I hear about the "about to lock the arena"
callback. Wouldn't hurt, of course, but it's also a new idea.
"Immediately", of course, may be misleading: if another thread is
waiting for the lock, the lock will not be available until that thread
is done with it.
There's a third lock operation, of course: _trylock, used for
(invasively) checking whether a mutex is currently available. Do we
want a pair of callbacks for that, or a third callback, or nothing at
all?
> With that, we could defer the application code of
> these signal handlers until after the arena is free to be accessed
> again.
We could block the appropriate signals before (in some cases, quite a
while before) we take the arena lock and unblock them after we release
it. That's not obviously the best solution, but it's the only one this
change would enable, AFAICS.
Running signal handler code from C without ever blocking signals at the
OS level is much more complicated, and I'm not convinced it would work
even with atomic types.
This would also require the OS to continue guaranteeing full POSIX
signal semantics while a "SIGSEGV" exception is being handled, since
that involves taking the arena lock.
> Alternatively, if MPS already has a solution for such applications
> that use signals, we'd like to hear what they suggest.
That's a useful question to ask, of course. My understanding is that
MPS is configured mostly at build time, and your idea would amount to
creating a replacement for lockix.c and lockw3.c which allows blocking
signals.
> As background, you can point them to this discussion:
>
> https://lists.gnu.org/archive/html/emacs-devel/2024-06/msg00568.html
I think the polite thing to do would be to agree on a short but accurate
summary of what it is we want, explaining why it would be helpful (it
may simplify things but isn't required for correctness).
Pip
next prev parent reply other threads:[~2025-01-02 12:34 UTC|newest]
Thread overview: 133+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-28 13:24 igc, macOS avoiding signals Sean Devlin
2024-12-28 13:28 ` Gerd Möllmann
2024-12-28 14:31 ` Eli Zaretskii
2024-12-28 14:45 ` Gerd Möllmann
2024-12-30 7:13 ` Gerd Möllmann
2024-12-30 7:23 ` Gerd Möllmann
2024-12-30 7:39 ` Helmut Eller
2024-12-30 7:51 ` Gerd Möllmann
2024-12-30 8:02 ` Helmut Eller
2024-12-30 8:47 ` Gerd Möllmann
2024-12-30 9:29 ` Helmut Eller
2024-12-30 9:47 ` Helmut Eller
2024-12-30 11:54 ` Gerd Möllmann
2024-12-30 10:05 ` Gerd Möllmann
2024-12-30 10:27 ` Helmut Eller
2024-12-30 11:53 ` Gerd Möllmann
2024-12-30 14:54 ` Eli Zaretskii
2024-12-30 15:05 ` Gerd Möllmann
2024-12-30 15:05 ` Pip Cet via Emacs development discussions.
2024-12-30 12:32 ` Pip Cet via Emacs development discussions.
2024-12-30 14:24 ` Eli Zaretskii
2024-12-30 14:59 ` Helmut Eller
2024-12-30 15:15 ` Eli Zaretskii
2024-12-30 15:24 ` Helmut Eller
2024-12-30 15:25 ` Pip Cet via Emacs development discussions.
2024-12-30 15:34 ` Gerd Möllmann
2024-12-30 19:02 ` Helmut Eller
2024-12-30 20:03 ` Pip Cet via Emacs development discussions.
2024-12-30 15:30 ` Gerd Möllmann
2024-12-30 16:57 ` Helmut Eller
2024-12-30 17:41 ` Gerd Möllmann
2024-12-30 17:49 ` Pip Cet via Emacs development discussions.
2024-12-30 18:33 ` Helmut Eller
2024-12-30 17:49 ` Eli Zaretskii
2024-12-30 18:37 ` Gerd Möllmann
2024-12-30 19:15 ` Eli Zaretskii
2024-12-30 19:55 ` Gerd Möllmann
2024-12-31 7:34 ` Helmut Eller
2024-12-31 9:19 ` Gerd Möllmann
2024-12-31 9:51 ` Helmut Eller
2024-12-31 10:00 ` Gerd Möllmann
2024-12-31 13:49 ` Pip Cet via Emacs development discussions.
2024-12-31 14:13 ` Eli Zaretskii
2024-12-31 9:51 ` Gerd Möllmann
2024-12-31 13:18 ` Eli Zaretskii
2024-12-31 14:15 ` Gerd Möllmann
2024-12-31 14:27 ` Eli Zaretskii
2024-12-31 15:05 ` Gerd Möllmann
2024-12-31 15:14 ` Eli Zaretskii
2024-12-31 15:20 ` Gerd Möllmann
2024-12-31 15:12 ` Helmut Eller
2024-12-31 15:31 ` Gerd Möllmann
2024-12-31 15:37 ` Helmut Eller
2024-12-31 15:39 ` Gerd Möllmann
2024-12-31 10:09 ` Pip Cet via Emacs development discussions.
2024-12-31 13:27 ` Eli Zaretskii
2024-12-31 14:29 ` Pip Cet via Emacs development discussions.
2024-12-31 14:34 ` Eli Zaretskii
2024-12-31 15:08 ` Gerd Möllmann
2025-01-03 18:37 ` Helmut Eller
2025-01-03 19:55 ` Eli Zaretskii
2025-01-03 20:28 ` Pip Cet via Emacs development discussions.
2025-01-04 7:01 ` Gerd Möllmann
2025-01-04 8:02 ` Gerd Möllmann
2025-01-04 8:34 ` Eli Zaretskii
2025-01-04 9:02 ` Gerd Möllmann
2025-01-04 9:59 ` Eli Zaretskii
2025-01-04 10:22 ` Gerd Möllmann
2025-01-04 13:59 ` Helmut Eller
2025-01-04 14:15 ` Gerd Möllmann
2025-01-04 14:17 ` Eli Zaretskii
2025-01-04 14:55 ` Helmut Eller
2025-01-04 15:06 ` Eli Zaretskii
2025-01-04 16:02 ` Pip Cet via Emacs development discussions.
2025-01-04 17:13 ` Helmut Eller
2024-12-31 15:07 ` Gerd Möllmann
2024-12-31 13:14 ` Eli Zaretskii
2024-12-31 14:19 ` Pip Cet via Emacs development discussions.
2024-12-31 14:31 ` Eli Zaretskii
2024-12-31 14:40 ` Helmut Eller
2024-12-31 14:55 ` Gerd Möllmann
2024-12-31 15:07 ` Eli Zaretskii
2024-12-31 15:13 ` Gerd Möllmann
2024-12-31 15:16 ` Helmut Eller
2025-01-02 8:37 ` Stefan Kangas
2025-01-02 9:05 ` Eli Zaretskii
2025-01-02 10:00 ` Helmut Eller
2025-01-02 12:34 ` Pip Cet via Emacs development discussions. [this message]
2025-01-02 13:08 ` Gerd Möllmann
2025-01-02 15:42 ` Eli Zaretskii
2025-01-02 17:56 ` Pip Cet via Emacs development discussions.
2024-12-30 12:42 ` Pip Cet via Emacs development discussions.
2024-12-30 13:40 ` Gerd Möllmann
2024-12-30 13:53 ` Pip Cet via Emacs development discussions.
2024-12-30 14:02 ` Gerd Möllmann
2024-12-30 14:32 ` Pip Cet via Emacs development discussions.
2024-12-30 14:52 ` Gerd Möllmann
2024-12-30 11:18 ` Pip Cet via Emacs development discussions.
2024-12-30 12:23 ` Gerd Möllmann
2024-12-30 11:11 ` Pip Cet via Emacs development discussions.
2024-12-30 12:13 ` Gerd Möllmann
2024-12-30 10:53 ` Pip Cet via Emacs development discussions.
2024-12-30 10:46 ` Pip Cet via Emacs development discussions.
2024-12-30 12:00 ` Gerd Möllmann
2024-12-30 12:07 ` Gerd Möllmann
2024-12-28 15:12 ` Pip Cet via Emacs development discussions.
2024-12-28 17:30 ` Eli Zaretskii
2024-12-28 18:40 ` Pip Cet via Emacs development discussions.
2024-12-28 18:50 ` Eli Zaretskii
2024-12-28 19:07 ` Eli Zaretskii
2024-12-28 19:20 ` Pip Cet via Emacs development discussions.
2024-12-28 19:36 ` Eli Zaretskii
2024-12-28 20:54 ` Pip Cet via Emacs development discussions.
2024-12-29 5:51 ` Eli Zaretskii
2024-12-28 19:15 ` Pip Cet via Emacs development discussions.
2024-12-28 19:30 ` Eli Zaretskii
2024-12-28 16:29 ` Pip Cet via Emacs development discussions.
2024-12-29 2:21 ` Sean Devlin
2024-12-29 12:22 ` Pip Cet via Emacs development discussions.
2024-12-29 15:01 ` Gerd Möllmann
2024-12-29 19:44 ` Pip Cet via Emacs development discussions.
2024-12-30 6:16 ` Gerd Möllmann
2024-12-30 12:51 ` Gerd Möllmann
2024-12-30 13:09 ` Pip Cet via Emacs development discussions.
2024-12-30 13:28 ` Gerd Möllmann
2024-12-30 5:24 ` Sean Devlin
2024-12-30 6:17 ` Gerd Möllmann
2024-12-30 5:23 ` Sean Devlin
-- strict thread matches above, loose matches on Subject: below --
2024-12-28 6:40 Gerd Möllmann
2024-12-28 12:49 ` Pip Cet via Emacs development discussions.
2024-12-28 12:55 ` Gerd Möllmann
2024-12-28 13:50 ` Óscar Fuentes
2024-12-29 8:02 ` Helmut Eller
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=87seq1l7ik.fsf@protonmail.com \
--to=emacs-devel@gnu.org \
--cc=eliz@gnu.org \
--cc=eller.helmut@gmail.com \
--cc=gerd.moellmann@gmail.com \
--cc=pipcet@protonmail.com \
--cc=stefankangas@gmail.com \
/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.