GNU bug report logs -
#65060
29.1.50; display_count_lines segv
Previous Next
Reported by: Kai Ma <justksqsf <at> gmail.com>
Date: Fri, 4 Aug 2023 21:43:01 UTC
Severity: normal
Found in version 29.1.50
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> From: Kai Ma <justksqsf <at> gmail.com>
> Date: Sat, 12 Aug 2023 15:28:16 +0800
> Cc: 65060 <at> debbugs.gnu.org
>
> > On Aug 12, 2023, at 14:50, Eli Zaretskii <eliz <at> gnu.org> 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. */
This bug report was last modified 1 year and 340 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.