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#65060: 29.1.50; display_count_lines segv Date: Sat, 12 Aug 2023 11:41:17 +0300 Message-ID: <83msywejpu.fsf@gnu.org> References: <83wmyat3b2.fsf@gnu.org> <835y5kg3f7.fsf@gnu.org> <325C6C15-2066-4331-8948-11BEC717ADE9@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22909"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65060@debbugs.gnu.org To: Kai Ma Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 12 10:41: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 1qUkBV-0005oP-8M for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Aug 2023 10:41:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qUkBE-0002OK-Ig; Sat, 12 Aug 2023 04:41:04 -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 1qUkBC-0002O6-H3 for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 04:41:02 -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 1qUkBC-0000o0-8W for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 04:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qUkBC-0007GY-40 for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 04:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Aug 2023 08:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65060 X-GNU-PR-Package: emacs Original-Received: via spool by 65060-submit@debbugs.gnu.org id=B65060.169182965427910 (code B ref 65060); Sat, 12 Aug 2023 08:41:02 +0000 Original-Received: (at 65060) by debbugs.gnu.org; 12 Aug 2023 08:40:54 +0000 Original-Received: from localhost ([127.0.0.1]:48682 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUkB4-0007G6-Al for submit@debbugs.gnu.org; Sat, 12 Aug 2023 04:40:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60398) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUkB1-0007Fq-FQ for 65060@debbugs.gnu.org; Sat, 12 Aug 2023 04:40:52 -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 1qUkAw-0000hp-41; Sat, 12 Aug 2023 04:40:46 -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=TPSIFTqV884AcDXpUuk98wHmAlh0mxbJliREIZ0WVPM=; b=PYn8kUSeoUTs gA9qvWFrKDI7ZmsQf7KnyrS57Nd75ObFQYtS5vKtxTzn1pBuN2nwQu76yVN1LCnc0lZ8xrgpbdjKt jabhid3EaOlm5k3/UTPEnhP6/nG4Y/uu228fG2ywbToAR49ZgJACOxFsUr6ZXEDciibT7dkChNGwh DUjIHCD3hQhGQvTBXloTbEWF8KRdN8Ym02m2YQpn4+mPWNe6XmNYt38tRoiJkZDsuktiGDyJ9xu/w ZE29NflGA2gk5y/BzgamGub4Hlk2v/d1+wWy9avmZ2oQVLgN7P8pd5eGBVhLUhLDEwQl4ouVwyhhi 0aK0seSrOSGX0WM4Q2+1Cg==; In-Reply-To: <325C6C15-2066-4331-8948-11BEC717ADE9@gmail.com> (message from Kai Ma on Sat, 12 Aug 2023 15:28:16 +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:267288 Archived-At: > From: Kai Ma > Date: Sat, 12 Aug 2023 15:28:16 +0800 > Cc: 65060@debbugs.gnu.org > > > On Aug 12, 2023, at 14:50, Eli Zaretskii wrote: > > > > Ping! Can you please help me finish investigating this bug by > > providing the information I asked for? Armed with that information, I > > think I will be able to find a solution. > > Sorry for the late reply! > > cursor (before do) = 0x0 > * GPT_BYTE = 3072 > * GAP_SIZE = 2000 > * BEG_ADDR = 0x0 > * current_buffer->text->beg = 0x0 > > cursor (before memchr) = 0x0 > * GPT_BYTE = 3072 > * GAP_SIZE = 2000 > * BEG_ADDR = 0x0 > * current_buffer->text->beg = 0x0 Thanks. My guess was correct: the buffer in question was killed. Could you please try the patch below, and see if it avoids the crashes? The patch causes Emacs to signal an error when format-mode-line is called for a dead buffer, so if I did this correctly, you should see that Emacs no longer crashes, but there are error messages about a dead buffer in *Messages*. If this is what happens, you should then take this up with the dirvish developers, and ask them to avoid calling format-mode-line for a killed buffer. diff --git a/src/fns.c b/src/fns.c index 2ed62d6..af5f947 100644 --- a/src/fns.c +++ b/src/fns.c @@ -6123,6 +6123,9 @@ DEFUN ("line-number-at-pos", Fline_number_at_pos, { ptrdiff_t pos_byte, start_byte = BEGV_BYTE; + if (!BUFFER_LIVE_P (current_buffer)) + error ("Attempt to count lines in a dead buffer"); + if (MARKERP (position)) { /* We don't trust the byte position if the marker's buffer is diff --git a/src/xdisp.c b/src/xdisp.c index 2250897..1141707 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -27653,6 +27653,8 @@ DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line, if (NILP (buffer)) buffer = w->contents; CHECK_BUFFER (buffer); + if (!BUFFER_LIVE_P (XBUFFER (buffer))) + error ("Attempt to format a mode line for a dead buffer"); /* Make formatting the modeline a non-op when noninteractive, otherwise there will be problems later caused by a partially initialized frame. */