emacs-devel
[Top][All Lists]
Advanced

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

Re: MPS: profiler


From: Pip Cet
Subject: Re: MPS: profiler
Date: Fri, 21 Jun 2024 08:23:16 +0000

On Thursday, June 20th, 2024 at 19:24, Ihor Radchenko <yantar92@posteo.net> 
wrote:
> I am playing around with scratch/igc branch for fun, and there is one
> crash that I can reproduce quite consistently.
> 
> All it takes is (1) compile Emacs without native-compilation support;
> (2) open Emacs; (3) M-x profiler-start; (4) run a complex operation.
> 
> Steps to reproduce:
> 
> 1. emacs -Q doc/misc/org.org
> 2. M-x profiler-start RET cpu RET
> 3. M-: (org-element-parse-buffer) RET
> 
> Without step 2, no crash.

Just sharing some information from a private discussion with Ihor:

I can reproduce this locally. I can also "fix" it locally, but the problem 
seems more complicated since Ihor reports the fix isn't working for him.

1. MPS uses SIGSEGV internally, usually transparently to the client program.

2. The profiler uses SIGPROF, then runs complicated code in the handler. My 
understanding is it's carefully tuned not to trigger traditional GC, but it can 
and will cause (handled) SIGSEGV.

3. MPS isn't reentrant enough to handle a SIGSEGV while it's handling a 
SIGSEGV, and will die with one of a number of errors.

The right thing to do, IMHO, is to let MPS know that it should block SIGPROF 
(and any other signals that might use managed memory) while handling SIGSEGV. 
Unfortunately, the MPS code in current git doesn't have facilities to do that, 
so I've applied this patch to MPS, which works here but doesn't for Ihor:

diff --git a/code/protsgix.c b/code/protsgix.c
index 966569c92..7c60d4fa2 100644
--- a/code/protsgix.c
+++ b/code/protsgix.c
@@ -143,7 +143,7 @@ void ProtSetup(void)
   int result;
 
   sa.sa_sigaction = sigHandle;
-  result = sigemptyset(&sa.sa_mask);
+  result = sigfillset(&sa.sa_mask);
   AVER(result == 0);
   sa.sa_flags = SA_SIGINFO | SA_RESTART;
 
Hope any of this helps,
Pip



reply via email to

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