unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: storm@cua.dk (Kim F. Storm)
Cc: emacs-devel@gnu.org
Subject: Re: Mysterious redisplay problem and a trap in xdisp.c
Date: 09 Feb 2002 21:59:48 +0100	[thread overview]
Message-ID: <5xadui5q2j.fsf@kfs2.cua.dk> (raw)


Hi Gerd,
Eli suggested I forwarded this to you.
There seem to be a problem with make_gap_smaller.

Since the posting below, I have tried the following steps (after starting emacs -q):

1) Setting gc-cons-threshold to 100 -> problem does not occur
2) M-x column-number-mode  -> problem occurs
3) M-x tool-bar-mode -> problem goes away

"Kim F. Storm" <storm@cua.dk> writes:

> I was trying to track down a redisplay problem I've seen lately with
> the CVS emacs:
> 
> While typing in some text in a buffer, emacs suddenly decides to
> insert a new line instead of the character I typed.  But if I do C-l,
> there is only one line, and the character I typed magically reappears.
> 
> I've only seen this with column-number-mode turned on, so the rest of
> you may not have noticed.
> 
> When this happens, the column number continues to increment relative
> to the original line start (and the bogus line wrap), but continuation
> glyphs are shown "correctly" in the fringe when the second line
> reaches the right margin and wraps into the third line.
> 

I made a small change to redisplay_internal so that instead of testing
on w->column_number_displayed, it just sets w->update_mode_line
unconditionally, i.e.

#if 0
  /* If %c is in the mode line, update it if needed.  */
  if (!NILP (w->column_number_displayed)
      /* This alternative quickly identifies a common case
	 where no change is needed.  */
      && !(PT == XFASTINT (w->last_point)
	   && XFASTINT (w->last_modified) >= MODIFF
	   && XFASTINT (w->last_overlay_modified) >= OVERLAY_MODIFF)
      && XFASTINT (w->column_number_displayed) != current_column ())
#endif
    w->update_mode_line = Qt; 

This makes the problem appear without enabling column-number-mode.

In addition, I set the modeline-format to "-" and the problem still
appears, so it is not related to the mode-line as such. 

However, if I turn off the tool-bar (M-x tool-bar-mode), the
problem seems to disappear.


I have now tracked the problem down to the following change:

2001-12-11  Andrew Innes  <andrewi@gnu.org>

	* insdel.c (make_gap) [DOUG_LEA_MALLOC]: Call make_gap_smaller if
	arg is negative.

If I comment out the call to make_gap_smaller in make_gap, the problem
goes away!

I placed a breakpoint on entry to make_gap_smaller, and except for a
few calls during startup, it seems that every time it is called
the false newline problem is seen.

But it is never(?) called when I turn off the tool-bar (except if I
make an explicit M-x garbage-collect) But maybe that is because using
the tool-bar causes the automatic garbage collection to happen more
frequently.


Here are some examples of contents of current_buffer->text on entry
and exit from that function when the problem is seen:


Breakpoint 3, make_gap_smaller (nbytes_removed=1728) at insdel.c:587
587       if (GAP_SIZE - nbytes_removed < 20)
(gdb) p *current_buffer->text
$19 = {
  beg = 0x84f4ca0 ";; This buffer is for notes you don't want to save, and for Lis
p evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 208,
  z = 1044,
  gpt_byte = 208,
  z_byte = 1044,
  gap_size = 1832,
  modiff = 1088,
  save_modiff = 0,
  overlay_modiff = 2,
  beg_unchanged = 207,
  end_unchanged = 836,
  unchanged_modified = 1088,
  overlay_unchanged_modified = 2,
  intervals = 0x0,
  markers = 674307420
}
(gdb) fin
Run till exit from #0  make_gap_smaller (nbytes_removed=1728) at insdel.c:587
make_gap (nbytes_added=-1728) at insdel.c:639
639     }
(gdb) p *current_buffer->text
$20 = {
  beg = 0x84f4ca0 ";; This buffer is for notes you don't want to save, and for Lis
p evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 208,
  z = 1044,
  gpt_byte = 208,
  z_byte = 1044,
  gap_size = 104,
  modiff = 1088,
  beg_unchanged = 1147,
  end_unchanged = 836,
  unchanged_modified = 1088,
  overlay_unchanged_modified = 2,
  intervals = 0x0,
  markers = 674307420
}
(gdb)

Breakpoint 3, make_gap_smaller (nbytes_removed=1748) at insdel.c:587
587       if (GAP_SIZE - nbytes_removed < 20)
(gdb) p *current_buffer->text
$21 = {
  beg = 0x84d0870 ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;
then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 1170,
  z = 1274,
  gpt_byte = 1170,
  z_byte = 1274,
  gap_size = 1875,
  modiff = 1318,
  save_modiff = 0,
  overlay_modiff = 2,
  beg_unchanged = 1169,
  end_unchanged = 104,
  unchanged_modified = 1318,
  overlay_unchanged_modified = 2,
  intervals = 0x0,
  markers = 674306720
}
(gdb) fin
Run till exit from #0  make_gap_smaller (nbytes_removed=1748) at insdel.c:587
make_gap (nbytes_added=-1748) at insdel.c:639
639     }
(gdb) p *current_buffer->text
$22 = {
  beg = 0x84d0870 ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;
then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 1170,
  z = 1274,
  gpt_byte = 1170,
  z_byte = 1274,
  gap_size = 127,
  modiff = 1318,
  save_modiff = 0,
  overlay_modiff = 2,
  beg_unchanged = 1400,
  end_unchanged = 104,
  unchanged_modified = 1318,
  overlay_unchanged_modified = 2,
  intervals = 0x0,
  markers = 674306720
}
(gdb)  


If I try an explicit garbage collection, the following behaviour
is seen:
 
Breakpoint 3, make_gap_smaller (nbytes_removed=983) at insdel.c:587
587       if (GAP_SIZE - nbytes_removed < 20)
(gdb) p *current_buffer->text
$26 = {
  beg = 0x84e44c0 ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;
then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 1344,
  z = 4019,
  gpt_byte = 1344,
  z_byte = 4019,
  gap_size = 1384,
  modiff = 4063,
  save_modiff = 0,
  overlay_modiff = 6,
  beg_unchanged = 1343,
  end_unchanged = 2675,
  unchanged_modified = 4063,
  overlay_unchanged_modified = 6,
  intervals = 0x0,
  markers = 675045032
}
(gdb) fin
Run till exit from #0  make_gap_smaller (nbytes_removed=983) at insdel.c:587
make_gap (nbytes_added=-983) at insdel.c:639
639     }
(gdb) p *current_buffer->text
$27 = {
  beg = 0x84e44c0 ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;
then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 1344,
  z = 4019,
  gpt_byte = 1344,
  z_byte = 4019,
  gap_size = 401,
  modiff = 4063,
  save_modiff = 0,
  overlay_modiff = 6,
  beg_unchanged = 4419,
  end_unchanged = 2675,
  unchanged_modified = 4063,
  overlay_unchanged_modified = 6,
  intervals = 0x0,
  markers = 675045032
}
(gdb)          


 
Breakpoint 3, make_gap_smaller (nbytes_removed=1322) at insdel.c:587
587       if (GAP_SIZE - nbytes_removed < 20)
(gdb) p *current_buffer->text
$29 = {
  beg = 0x84b78d8 ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;
then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 887,
  z = 4636,
  gpt_byte = 887,
  z_byte = 4636,
  gap_size = 1785,
  modiff = 4680,
  save_modiff = 0,
  overlay_modiff = 6,
  beg_unchanged = 886,
  end_unchanged = 3749,
  unchanged_modified = 4680,
  overlay_unchanged_modified = 6,
  intervals = 0x0,
  markers = 675044292
}
(gdb) fin
Run till exit from #0  make_gap_smaller (nbytes_removed=1322) at insdel.c:587
make_gap (nbytes_added=-1322) at insdel.c:639
639     }
(gdb) p *current_buffer->text
$30 = {
  beg = 0x84b78d8 ";; This buffer is for notes you don't want to save, and for Lisp evaluation.\n;; If you want to create a file, visit that file with C-x C-f,\n;;
then enter the text in that file's own buffer.\nnnnnnnnnnn"...,
  gpt = 887,
  z = 4636,
  gpt_byte = 887,
  z_byte = 4636,
  gap_size = 463,
  modiff = 4680,
  save_modiff = 0,
  overlay_modiff = 6,
  beg_unchanged = 5098,
  end_unchanged = 3749,
  unchanged_modified = 4680,
  overlay_unchanged_modified = 6,
  intervals = 0x0,
  markers = 675044292
}
(gdb) 


I have tried hard to understand what's going on, but maybe someone
else is able to see what might be wrong here...

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


             reply	other threads:[~2002-02-09 20:59 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-09 20:59 Kim F. Storm [this message]
2002-02-09 22:42 ` Mysterious redisplay problem and a trap in xdisp.c Gerd Moellmann
2002-02-09 23:06   ` Kim F. Storm
2002-02-11  2:09     ` Richard Stallman
2002-02-11  8:27       ` Kim F. Storm
  -- strict thread matches above, loose matches on Subject: below --
2002-02-07 12:59 Kim F. Storm
2002-02-07 19:47 ` Eli Zaretskii
2002-02-08 13:57 ` Richard Stallman
2002-02-08 20:50 ` Kim F. Storm
2002-02-09  7:25   ` Eli Zaretskii
2002-02-10  5:17   ` Richard Stallman
2002-02-11  2:09     ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5xadui5q2j.fsf@kfs2.cua.dk \
    --to=storm@cua.dk \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).