From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thiago Melo Newsgroups: gmane.emacs.bugs Subject: bug#63589: [PATCH] 29.0.91; crash after creating graphical frames via emacsclient when compiled with cairo-xcb Date: Mon, 22 May 2023 19:21:36 +0000 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="729"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Po Lu , 63589@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 22 21:23:21 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 1q1B7o-000AU8-7E for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 May 2023 21:23:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1B7c-0004uj-1u; Mon, 22 May 2023 15:23: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 1q1B7W-0004re-Ot for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 15:23:06 -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 1q1B7V-0007mF-QC for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 15:23:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q1B7V-0005yx-La for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 15:23:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thiago Melo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 May 2023 19:23:01 +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.168478334022939 (code B ref 63589); Mon, 22 May 2023 19:23:01 +0000 Original-Received: (at 63589) by debbugs.gnu.org; 22 May 2023 19:22:20 +0000 Original-Received: from localhost ([127.0.0.1]:36682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1B6q-0005xu-B5 for submit@debbugs.gnu.org; Mon, 22 May 2023 15:22:20 -0400 Original-Received: from mail-yw1-f182.google.com ([209.85.128.182]:52260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q1B6o-0005xi-Rn for 63589@debbugs.gnu.org; Mon, 22 May 2023 15:22:19 -0400 Original-Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-561d611668eso82412617b3.0 for <63589@debbugs.gnu.org>; Mon, 22 May 2023 12:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684783333; x=1687375333; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=TGVtXHoHoV8/7VSEBj40uSyvbjcmdsM2dhwmn2WQY0Q=; b=HGnZc9z+UiFEtTirZGzHhnMa+yA7EGKZPWQmXsv2K+L4FbRioDx5sIrWiPOkqM9Yu/ Z+lk94fQkvQuxkS32NDwGOcUJnvPrvb81lV8B7MuMfqiqasangr+nOxdqoqhH1vuviPD LdIuixdyKJo8yWm9wksSoaRUQzyKd0i84oHJj4j3hIEuVW3Cu8ZE+tLMiIcdMgff9E3X LasHHTkLAYNeuhAYHnkchY8Pldz3FnOq3WlLyb9rV2QWvtvAXMPKRdFi0eHUBP309Wja UesGa7GIstiIv9lKcaf8EF/OKbC9MCFG9SUQwpL6hGf+3KEAqz7oON21ukZhF4dEi6Ci LS+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684783333; x=1687375333; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TGVtXHoHoV8/7VSEBj40uSyvbjcmdsM2dhwmn2WQY0Q=; b=C9LcWPWI0p5wLaU1UECaWuP5sygWd1p+tl7eSoTZj7c1dilPVX/eEuXVKVD0MBgs+t YAt1eb+E5uPRQCyW166UKc8JKx+WHUWrCdKB7l2GNiabmtJPUjrfcMUjizwKdeuDNd1R u71Ok/p5nhyAEwn27VxrCdlK0Oo9kb+6lD/oBDYW7Y7U/9MWO6LWfnrcwaoBgKHA/V6X j458FqFpw1fHA1V3GHFha6ahP2W/4RhLbePOkUrhBx5NVXfwGG4Vytv/PVODvdhfnf2o iHDvpXzQR0jnXTY0SDGPaHF1+JlaEFV7u5guVuxIi+MjXz5rHewUFexOCi6R7PKXszD8 0GoQ== X-Gm-Message-State: AC+VfDzt4GukUU4PKlXBanExVGDb0WsH7KUifaiXgekWoQJ/i2ShuFzn BcYHfQJf7ye9Lbl2T1g1hjuEUn23QpuoG2McCZw= X-Google-Smtp-Source: ACHHUZ74kmXth37m1ECi8XsYnmebPqhBi02uKKBjzpwH0GgJX1FoXq6XMt9uDJVBSCVoyUdsZ/Rc7PhcoUju4HeDuJU= X-Received: by 2002:a0d:ebd7:0:b0:55a:9e6e:516 with SMTP id u206-20020a0debd7000000b0055a9e6e0516mr13319352ywe.1.1684783332997; Mon, 22 May 2023 12:22:12 -0700 (PDT) In-Reply-To: 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:262185 Archived-At: > > > > > 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 Caveat: I've tested it, the errors and crash were gone, but it likely introduces potential leaks in this build (which probably happens with GTK and Lucid builds too anyway, from what I've seen in the wild). No free lunch.