From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#63589: [PATCH] 29.0.91; crash after creating graphical frames via emacsclient when compiled with cairo-xcb Date: Tue, 23 May 2023 08:30:49 +0800 Message-ID: <874jo3yjly.fsf@yahoo.com> References: <871qj9246a.fsf@yahoo.com> <83o7mdrc3y.fsf@gnu.org> <83bkidr37i.fsf@gnu.org> <87wn11yyi4.fsf@yahoo.com> <87edn9ytbo.fsf@yahoo.com> <835y8kr5re.fsf@gnu.org> <87pm6sy5rb.fsf@yahoo.com> <83wn10ppa1.fsf@gnu.org> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4631"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63589@debbugs.gnu.org, Eli Zaretskii To: Thiago Melo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 23 02:32:33 2023 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 1q1Fx3-00011o-08 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 23 May 2023 02:32:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1Fwa-0003Pd-Sx; Mon, 22 May 2023 20:32:08 -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 1q1FwY-0003PL-Jc for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 20:32:03 -0400 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 1q1FwY-0001Z9-Av for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 20:32:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q1FwY-0007Ak-6q for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 20:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 May 2023 00:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63589 X-GNU-PR-Package: emacs Original-Received: via spool by 63589-submit@debbugs.gnu.org id=B63589.168480187027483 (code B ref 63589); Tue, 23 May 2023 00:32:02 +0000 Original-Received: (at 63589) by debbugs.gnu.org; 23 May 2023 00:31:10 +0000 Original-Received: from localhost ([127.0.0.1]:37323 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1Fvh-00079D-DP for submit@debbugs.gnu.org; Mon, 22 May 2023 20:31:09 -0400 Original-Received: from sonic310-25.consmr.mail.ne1.yahoo.com ([66.163.186.206]:43417) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1Fvc-00078f-Od for 63589@debbugs.gnu.org; Mon, 22 May 2023 20:31:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1684801859; bh=eetrn3kPqDXayuUTJABpYtNRmUTcylfvKK+se1P68FQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=G4PRp0n/29esQcxV+mdclUIvjBv2tIRR0PoTPOhcfCV6R+jeDI1Av3W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GCOx9hqw06 ZTpMcIQBdZJ76AHLsOcOtGR2k9fQ75VVG41KeqXIG.IKsHJEaVGuIOupGaHMdTusE3QiEeNdvkiA TqQ_UsehaREJZgm00CUl6EyuS1PzQQ3YJ0AXFDY4D8Ewi3JJaJ1qYAlUlbXJ2GNWrqfNdqpYM7HC 1gYXQYuboCK.fu20COkRmnRg2pkuXhnN90D0dahCK2Zj7GQHRMbP59vFq5QYKedzj2LR5n2vhYLJ phCO19or5HxFEOuXfOvE8O20vHNGhlXVeqIE1fXx9haxVx_IfkAV5Dd8UFTIhR6gLiT0DuP_L4kO KPG6exoL7t7jQAlq64dHvmitpERZjFyobAZi26KOUV1gLvFjds._OAqRtnTpxgv6DifkQWCFMKKL hga0qEkclisACrC9bfS4tQxUfsdnYj0ZQCmaiOr1vvTlKJYemWJL22ra1ObtNcVEmOB0nuN16Jav 1A0NCwP_d0Bu_.2QJYd0gfenxodgKFi3NxsdOG4Fuz8tv23VpwZZIBGsGsCml2v8a6HBIRb1Fgdt euEbKQgOIifiJ54pvY4AHGk8iREpDgSjYfrwwkAicJ X-Sonic-MF: X-Sonic-ID: 47e68661-0359-4f52-a3ba-9e4ae3c303cb Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Tue, 23 May 2023 00:30:59 +0000 Original-Received: by hermes--production-sg3-748897c457-fp9l7 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 3d627536836239de4ba6cc60f1a20197; Tue, 23 May 2023 00:30:53 +0000 (UTC) In-Reply-To: (Thiago Melo's message of "Mon, 22 May 2023 19:21:36 +0000") X-Mailer: WebService/1.1.21495 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:262199 Archived-At: Thiago Melo writes: >> > > > > What is the kind of situations in which these crashes could happen? >> > > > >> > > > Precisely that described in this bug report: when displays are closed >> > > > and reopened within a short time period. >> > > >> > > What kind of user-level situations could cause this? Is invoking >> > > emacsclient soon after deleting the last visible frame the only one? >> > > And what does "short time period" mean, quantitatively? milliseconds? >> > > seconds? minutes? >> > >> > Sorry, in my experience it seems that the time interval between >> > closing the display and opening it again doesn't matter. It seems to >> > be more about the amount of times that the display is closed and then >> > opened (which is often 3 times for me, for whatever reason). >> > >> > I'm testing it here again with Xvfb and an automation script, with a >> > 10 minutes delay after creating a single graphical frame, and another >> > 10 minutes delay after closing it and before creating a new one. I'll >> > report the results soon. >> > >> > Also, this bug seems more likely to happen when emacs is built without >> > a toolkit (which is was I've been testing so far), since the display >> > is always closed after the last graphical frame is closed. Which made >> > me realize, after looking at frame.c, that this bug might as well join >> > the family of Bug#5802, Bug#21509, Bug#23499, and Bug#27816. >> >> With 10 minutes intervals, I got the X errors previously mentioned by >> the 3rd time the display was opened, and then emacs crashed by the 5th >> time the display was opened. So, assuming that 10 minutes is close >> enough to infinity, we can say that the time interval doesn't matter. > > So, trying to gather everything into a summary here. > > To trigger the bug, all the following conditions must be met: > > - Emacs built without a toolkit > - Emacs built with Cairo-XCB > - Emacs started in daemon mode > - The user closes all graphical frames and creates a new one (manually > or programatically, duration in between doesn't matter, amount of > times is not certain) > > It goes into the `delete_frame' -> `Fdelete_terminal' -> > `x_delete_terminal' -> `XCloseDisplay' path, where cairo-xcb > references are not destroyed, leading to X errors and emacs crashing. > > What else I've tested so far, that didn't trigger the bug: > > - Closing the X Server > - xkill'ing graphical frames > > These two cases go into the `x_connection_closed' -> > `Fdelete_terminal' -> `x_delete_terminal' path, where `XCloseDisplay' > is not called. > > Other builds I've tested, that didn't trigger the bug: > > - GTK + Cairo-XCB > - Lucid + Cairo-XCB > > Which doesn't end up calling XCloseDisplay, since the terminal is not > deleted when the last graphical frame is closed (due to the infamous > longstanding GTK bug, Bug#5802, Bug#21509, Bug#23499, and Bug#27816). > > Considering all the above, I propose this smaller (and potentially > temporary) patch: > > #+begin_src diff > --- a/src/frame.c 2023-05-22 19:52:25.155145242 +0200 > +++ b/src/frame.c 2023-05-22 20:13:41.548566364 +0200 > @@ -2206,14 +2206,15 @@ > /* If needed, delete the terminal that this frame was on. > (This must be done after the frame is killed.) */ > terminal->reference_count--; > -#if defined (USE_X_TOOLKIT) || defined (USE_GTK) > +#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (USE_CAIRO_XCB) > /* FIXME: Deleting the terminal crashes emacs because of a GTK > bug. > https://lists.gnu.org/r/emacs-devel/2011-10/msg00363.html */ > > /* Since a similar behavior was observed on the Lucid and Motif > - builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), we now > - don't delete the terminal for these builds either. */ > + builds (see Bug#5802, Bug#21509, Bug#23499, Bug#27816), and builds > + without a toolkit together with Cairo-XCB support (Bug#63589), > + we now don't delete the terminal for these builds either. */ > if (terminal->reference_count == 0 > && (terminal->type == output_x_window > || terminal->type == output_pgtk)) > #+end_src We want closing displays (think x-delete-terminal) to still work on such builds if the user uses it.