Subject: Re: bug#15841: Display bugs with cache-long-lines non-nil

From: Stephen Berman <[email-masked]>
Date: Tue, 12 Nov 2013 11:03:47 +0100

On Tue, 12 Nov 2013 01:38:34 +0100 Stephen Berman <[email-masked]> wrote:

> On Mon, 11 Nov 2013 15:12:15 +0100 Stephen Berman <[email-masked]> wrote:
>
>> This change broke dired-maybe-insert-subdir.  Perhaps this should be a
>> new bug number, but since part of the breakage is display-related, I
>> decided to report it here.  To reproduce:
>>
>> 0. emacs -Q (built from trunk bzr 115033 or later)
>> 1. Open a directory in Dired, e.g. the Emacs source tree root.
>> 2. Put point on an entry listing a directory, e.g. admin.
>> 3. Type `i'.
>> => Emacs hangs.
>>
>> If I repeat the recipe but after step 1 type `M-: (setq cache-long-lines
>> nil)', then at step 3, `i' works as expected.
>>
>> Here are more details of the breakage:
>>
>> Typing `C-g' releases the hang and shows the admin subdirectory, but its
>> display is corrupted: (i) the "available" blocks information, which
>> should appear at the end of the "total" line, instead appears to the
>> right of the first entry `.' and is fontified with dired-directory face;
>> (ii) while all the entries of admin are listed below the `..' entry, the
>> entire line of each entry is fontified with dired-directory face, and
>> these lines cannot be accessed by vertical motion commands like `C-n' or
>> `C-p', though they can be with horizontal motion commands like `C-f' and
>> `C-p'.  In fact, all of these entries appear to Dired to be part of the
>> line of the `..' entry, and AFACT this is what causes the hang: Emacs
>> infloops in dired-move-to-filename because, when point appears to be at
>> eof, beginning-of-line moves it back to the start of the `..' entry.
>
> I tracked the problematic fontification and motion behavior to
> insert-directory in files.el: it happens during the loop when
> decode-coding-region is called on the file names of the subdirectory
> entries.  I stepped through the code with Edebug but could not tell why
> it goes wrong here, and I'm too tired to pursue it further now.  Also,
> when I step through this code, the "available" information is added at
> the end of the entire subdirectory listing, unlike what I observed above
> when just invoking `i' and then `C-g'.  I guess this is due to the
> interaction of redisplay with stepping through the code; it's still
> clear that the subdirectory listing is being treated as part of the line
> containing the `..' entry.

I set a breakpoint on decode_coding_object and stepped through it after
invoking `i', but the Dired display changed to show the problematic
fontification only upon exiting decode_coding_object.  I don't know how
to find out when cache_long_scans is checked other than manually tracing
the call chains of each subroutine of decode_coding_object, which is too
laborious.  Is it possible to have execution halt when cache_long_scans
is checked, and if so, how?  Or is there a better way to try to track
down this bug?

Steve Berman