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.bugs Subject: bug#60144: 30.0.50; PGTK Emacs crashes after signal Date: Sun, 18 Dec 2022 10:39:54 +0200 Message-ID: <83y1r5f6lh.fsf@gnu.org> References: <87edsxfop0.fsf@yahoo.com> <83359dgt7v.fsf@gnu.org> <87a63lfcz7.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32732"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 60144@debbugs.gnu.org, karl@karlotness.com To: Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 18 09:40:20 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1p6pDX-0008Nd-U9 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Dec 2022 09:40:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p6pDN-0000Cc-A2; Sun, 18 Dec 2022 03:40:09 -0500 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 1p6pDI-0000Bn-La for bug-gnu-emacs@gnu.org; Sun, 18 Dec 2022 03:40:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p6pDH-0005Kf-Ku for bug-gnu-emacs@gnu.org; Sun, 18 Dec 2022 03:40:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p6pDG-0003RC-E1 for bug-gnu-emacs@gnu.org; Sun, 18 Dec 2022 03:40:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Dec 2022 08:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60144 X-GNU-PR-Package: emacs Original-Received: via spool by 60144-submit@debbugs.gnu.org id=B60144.167135279613204 (code B ref 60144); Sun, 18 Dec 2022 08:40:02 +0000 Original-Received: (at 60144) by debbugs.gnu.org; 18 Dec 2022 08:39:56 +0000 Original-Received: from localhost ([127.0.0.1]:60861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6pDA-0003Qu-3t for submit@debbugs.gnu.org; Sun, 18 Dec 2022 03:39:56 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p6pD7-0003Qo-Rs for 60144@debbugs.gnu.org; Sun, 18 Dec 2022 03:39:54 -0500 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 1p6pD2-0005GW-Cw; Sun, 18 Dec 2022 03:39:48 -0500 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=ssrOZ5cCvXxmrUkoNvO8sWEvyW1Q6GbUoKctPOBQVkk=; b=JN74BUcs9j1u bFW5uISFeQpr5Kzr8H/1K8h5R5c7so9CAcyHbs1jjZ4k/xyXVYGSsEqIlDhxcb9aES6gYvCfJSpOo xArpj30uSj+yv0mNoIiCVgnV8aNRXUnmQW/tYY4tYN8wQj2C+gg2sTeNfgKE7Vo43jZ3v8/4QXWM/ bXoHOHuJT1cEMdvutiASv7agOrqA0k4ma0NRMl/+l9TBYxmzzgP46ydbyUe/RPwwkrB49eFLsusjm itgwVjWvQrZ3TNts7//xoUOgLbjzAGerOHmHWYcfgFQk9+6bQ3SUJQn/TzPYaA9tELIcEESTZV0/e qhG8ZMDX7MXv5eaLAryujg==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p6pD1-0007Cs-Ku; Sun, 18 Dec 2022 03:39:47 -0500 In-Reply-To: <87a63lfcz7.fsf@yahoo.com> (message from Po Lu on Sun, 18 Dec 2022 14:22:04 +0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:251339 Archived-At: > From: Po Lu > Cc: karl@karlotness.com, 60144@debbugs.gnu.org > Date: Sun, 18 Dec 2022 14:22:04 +0800 > > Eli Zaretskii writes: > > > You cannot require that from note_mouse_highlight, since it looks up > > text and overlay properties, and those can signal an error if the > > position is outside the valid/reachable range of buffer positions. > > How about simply wrapping those calls in > internal_catch_all/internal_condition_case? This is too drastic, IMO: it would deprive us of valuable diagnostics when note_mouse_highlight is called. Like in this case, for example: having the code signal an error allowed me to find a real bug. We were asking string_buffer_position_lim to check properties and overlays for positions outside the BEGV..ZV interval, which can never do anything useful, even if it isn't called in the PGTK context. I've now fixed that on the release branch. In general, note_mouse_highlight should never examine invalid buffer or string positions. If it does, it's a bug that needs to be fixed. > > Do you understand why note_mouse_highlight was called in this > > scenario? The backtrace seems strange: why should GTK care about our > > mouse highlight? > > What happens here is that Emacs is reading input through GTK, either > inside xg_select or the read_socket_hook. GTK then detects some mouse > motion and calls the motion event handler for the frame's widget, which > in turn calls note_mouse_movement. Why this fragile architecture of reading input events? Calling functions of our Lisp machine from context where those functions cannot signal an error is very dangerous, and cannot work well in Emacs. Why cannot we have the reads through GTK only deliver events to us, which we enqueue to our own event queue, and then we could process that queue in the safe context of the Lisp machine, as (AFAIK) we do on other platforms?