From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: MPS: a random backtrace while toying with gdb Date: Wed, 03 Jul 2024 14:50:15 +0300 Message-ID: <868qyibsp4.fsf@gnu.org> References: <87bk3jh8bt.fsf@localhost> <86msn1fk0c.fsf@gnu.org> <86h6d9dlyg.fsf@gnu.org> <86h6d8c52h.fsf@gnu.org> <86sewrc057.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33394"; mail-complaints-to="usenet@ciao.gmane.io" Cc: eller.helmut@gmail.com, gerd.moellmann@gmail.com, yantar92@posteo.net, emacs-devel@gnu.org To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 03 13:51:17 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sOyW4-0008QV-Vx for ged-emacs-devel@m.gmane-mx.org; Wed, 03 Jul 2024 13:51:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOyVD-00021a-AD; Wed, 03 Jul 2024 07:50:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOyVA-00020K-PG for emacs-devel@gnu.org; Wed, 03 Jul 2024 07:50:21 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOyV9-0002Q3-4o; Wed, 03 Jul 2024 07:50:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=efI6tVRpU2UjVJDciPoD+LWXIyq3jWdUTpcn0+J0D+s=; b=ah6aUkwLVwRE C5h3Rfe3OX8i68zKbFb8unZpP6+/fQk3r/U798Kx5iiazmm4++0Uz663aJN3FPQ7RdJex4sQGjJfR a1XDPBRM1X8lHBvCa+tjsn/Le2JadkppYmaRQ4kNVi65P1Ugf2hf+4mVxA2UwYzHVhl2ENnNYpBsD tjt+p2qGLU+P2KYChXQhFljxZMlzjs6PzOb7/C+1dE/nRAf29uaYew+IL7LaM8FYmhpVVMbC3LB20 P0WICR0QERPH2KuG+x1YL3H9h4HK2u2uTptR+294j2SHxSE3L/qJ2NF1Sxmy1QCSIcJiPnjZV8zWt ZQWkaRidPm3ivech9irgMw==; In-Reply-To: (message from Pip Cet on Wed, 03 Jul 2024 11:31:48 +0000) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:321249 Archived-At: > Date: Wed, 03 Jul 2024 11:31:48 +0000 > From: Pip Cet > Cc: Eli Zaretskii , eller.helmut@gmail.com, gerd.moellmann@gmail.com, yantar92@posteo.net, emacs-devel@gnu.org > > So what are the proposed solutions that are still on the table? I can think of these: > > 1. block signals around MPS calls and block signals while the MPS SIGSEGV handler is running > 2. handle signals in a special thread > 3. switch Emacs to an event loop model and handle all signals asynchronously I'd start with the first half of (1). It is not clear to me that the other part is needed, and in any case we need a reproducer for it first. Most of the crashes we've seen until now were not when the MPS handler was running. Also, didn't someone say that when the MPS SIGSEGV handler is active, we could detect that from our code and return doing nothing? > (1) is hard to do because we'd need to hijack the SIGSEGV handler and/or modify MPS > (3) is a very major change which would mean permanently losing features we want > (2) is very easy to do, but gets complicated for SIGPROF (which needs to be on the thread it's profiling) and emergency breakout signals which need to modify the main thread's state. > > I've tried (2) and it fixes the specific reproducer I posted yesterday, as it should do in theory. I believe it's the most flexible approach which still gives us well-defined semantics for signal handlers. We'd need to add per-thread signals for the specific cases mentioned above. And, of course, its pthread-specific. Doing (2) adds a whole lot of complexity to Emacs. Most importantly, we will be unable to access Lisp data safely, unwind-protect and the entire specpdl stuff generally cannot be used, and signaling an error would be fatal. So I'd rather avoid that.