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#72692: Emacs 31.05 (40eecd594ac) get SIGSEGV on Linux (Linux 6.6.45 Kde Wayland) Date: Sun, 18 Aug 2024 17:12:46 +0300 Message-ID: <86cym5zzq9.fsf@gnu.org> References: <8b1c8e1f-e0b9-4049-888c-3f723e0008a9@gmail.com> <87sev2gqc7.fsf@protonmail.com> <51a90b68-3958-4d6e-bfb1-1ea5a0e8ab11@gmail.com> <87le0ugp6i.fsf@protonmail.com> <6d4a3b17-a177-4b3b-8873-50662f56e304@gmail.com> <87h6bigoo5.fsf@protonmail.com> <7be3359e-4389-4bc6-bf98-b46a2a8a711c@gmail.com> <877ccegfxj.fsf@protonmail.com> <86h6biymv4.fsf@gnu.org> <8734n2gd2x.fsf@protonmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38486"; mail-complaints-to="usenet@ciao.gmane.io" Cc: execvy@gmail.com, 72692@debbugs.gnu.org To: Pip Cet Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 18 16:13:37 2024 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 1sfgf3-0009sG-74 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 18 Aug 2024 16:13:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sfgeq-0002go-PE; Sun, 18 Aug 2024 10:13:24 -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 1sfgeo-0002YS-DQ for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 10:13:22 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sfgen-0004mj-IU for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 10:13:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=kOBb+G9A57I1+a7zWcQfcUIQfM7C7RNTwuQCrqW1Nx4=; b=uR09YC64jwwdBJ1kt9a+VRwOEZ+ThxlH2IA+TSjqJuB8+xwCxVDISvhqRNsDOm4ladHBlDi16ukZ2Ga9FYCUe48IOsCwAX0KAuio7h2yhv2WsA/j6xP6jPXflSXvvn8O7sLgaDzIgos7okwUQ3m8tvU9AAtnjt9eXXWCUR4TAH1thHmCkW5aOvttajtsd84X+mHBURGNLrHI6HvOHCiDUGA5eDOW3fTkjsUoVHxUCqAfmDetHN0EXURPSOFOm8V5Bu92Ud88dM2aUAxrq6/7YfPQv5Xt9JyhX+j5mc/Igb1iCSbDAqTsVWouP+RsaJFYiywNUzJ8jCxrwcOS5o0QzA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sfgfR-0007l6-SV for bug-gnu-emacs@gnu.org; Sun, 18 Aug 2024 10:14:01 -0400 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 Aug 2024 14:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72692 X-GNU-PR-Package: emacs Original-Received: via spool by 72692-submit@debbugs.gnu.org id=B72692.172399042029781 (code B ref 72692); Sun, 18 Aug 2024 14:14:01 +0000 Original-Received: (at 72692) by debbugs.gnu.org; 18 Aug 2024 14:13:40 +0000 Original-Received: from localhost ([127.0.0.1]:56423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfgf6-0007kH-2Q for submit@debbugs.gnu.org; Sun, 18 Aug 2024 10:13:40 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:51246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sfgf4-0007k1-0q for 72692@debbugs.gnu.org; Sun, 18 Aug 2024 10:13:38 -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 1sfgeK-0004io-2b; Sun, 18 Aug 2024 10:12:52 -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=kOBb+G9A57I1+a7zWcQfcUIQfM7C7RNTwuQCrqW1Nx4=; b=mkQKWhXcwts/ ZMkbxbc3RLH3VcTrBgmrUN/DbFecTPuP+n+EaXYay/oAPGcK52Crr+TcEsHxKLsPfQsTUQnNbo9FM XtaYfzuuuB+Y7j1pWzwkfW1rp6nNbpPIW383rMv4iWUNULoGi1hDSno+ztDc02XalV1Pv4Lst9XZ8 vqBIdrGDLNfF5oRV+AhDhCEhWjIhL+uHZXD6dohEWr59LlbOwUmcedP4iGaHmcXFFmXuJoKOiNoUp KbiTi86ECTYvEsmCgV5UrP5BoCqs5mrW63x8y6+r1uISWox0PdmCv0fINwGLvw67MuXTWJTmuWtmx RHdYC8PfVbiE0WMVApo+KQ==; In-Reply-To: <8734n2gd2x.fsf@protonmail.com> (message from Pip Cet on Sun, 18 Aug 2024 13:44:41 +0000) 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:290324 Archived-At: > Date: Sun, 18 Aug 2024 13:44:41 +0000 > From: Pip Cet > Cc: execvy@gmail.com, 72692@debbugs.gnu.org > > "Eli Zaretskii" writes: > > >> Cc: 72692@debbugs.gnu.org > >> Date: Sun, 18 Aug 2024 12:43:06 +0000 > >> From: Pip Cet via "Bug reports for GNU Emacs, > >> the Swiss army knife of text editors" > >> > >> Thanks. That has a different fontset, so it looks like a fontset was > >> prematurely freed while still being referred to by a face. I think the > >> assumption made in xfaces.c, that it's always safe to free a fontset if > >> we're freeing the realized ASCII face, is incorrect. > > > > Why do you think that? free_realized_face frees a face, so what other > > face can still use the same fontset, if it's a so-called "ASCII face"? > > I was under the impression two faces could share the same fontset. That > certainly is what my debugging sessions so far indicate. Maybe that's > the bug? We are talking about a fontset identified by face->fontset. AFAIU, face->fontset is only non-negative for so-called "ASCII faces". > >> I can confirm that we're sometimes leaving a frame's fontset field > >> invalid by running this code: > > > > If face2->ascii_face is equal to face->ascii_face, > > Yes, face2->ascii_face == face == face->ascii_face. > > > then I see no > > reason not to free the fontset because of that other face. The > > comment in dispextern.h says: > > > > /* Fontset ID if for this face's fontset. Non-ASCII faces derived > > from the same ASCII face have the same fontset. */ > > int fontset; > > So, indeed, the fontset id is shared between the ASCII face and the > non-ASCII face. If we free the fontset because the ASCII face is > unrealized, but the non-ASCII face is not, we hit the bug... But AFAIK a non-ASCII face is always released together with its ASCII face, so how can this be a problem? A "non-ASCII face" is basically the same face as its "ASCII face" counterpart, it just uses a different font. An example would be some well-known face, like 'bold' or 'variable-pitch' or 'region' -- when we need to display a non-ASCII character in this face, and the "ASCII face"s font doesn't support the character, we internally create a new face that uses the same fontset as the "ASCII face". This new face basically shadows the "ASCII face" (and is never exposed to Lisp) and is for every practical purpose an integral part of that "ASCII face" -- they always go together. > > And how did you see that a frame's fontset was left invalid here? A > > frame doesn't have a fontset, AFAIK. > > I meant "face", sorry! The non-ASCII face remains in the font cache, > and its fontset is set to the newly freed fontset's ID, which is likely > soon to be reused; only if it isn't, we see a crash. That shouldn't happen, AFAIU, except for very brief periods of time, since we free the cached faces one by one, see free_realized_faces. > > I also think it might be unsafe to call 'message' from this place, > > because 'message' might trigger redisplay. It is better to call > > message_dolog or add_to_log (and ask the user to look at *Messages*). > > It is, thank you! Yes, fprintf or message_dolog would have been better. fprintf is indeed the safest, but it requires Emacs to be launched from the shell prompt.