#8 Editor hangs for a while before showing the article

open
nobody
None
5
2009-04-11
2009-04-11
Yuri
No

When I try to open a wiki page 'vim /wiki/wikipedia-en/France.mw' on FreeBSD-71 vim sits blank for a while.
'top' shows both python2.5 and vim consuming a lot of CPU while vim is blank.
But when I hit Ctrl-C shortly after I run a command (normally to interrupt loading of a long file) vim always shows a complete article.
Just to be clear here if I don't hit Ctrl-C it will sit blank for a long while with high CPU usage.

So wiki page is actually loaded very quickly but after that vim cycles and keeps trying to read at the end of file.

When I trace system calls with 'truss' I get the log below which keeps going many times while the problematic hanging is in progress.
read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
mmap(0x0,9437184,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 890241024 (0x35100000)
munmap(0x34800000,9437184) = 0 (0x0)
read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
mmap(0x0,9437184,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 880803840 (0x34800000)
munmap(0x35100000,9437184) = 0 (0x0)
read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
mmap(0x0,9437184,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 890241024 (0x35100000)
munmap(0x34800000,9437184) = 0 (0x0)
read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
<...keeps going this way...>

Discussion

  • Yuri
    Yuri
    2009-04-11

    I grabbed the system calls logwhen the file is opened. It shows that after then file is read (it was 92060 bytes) read never returns 0 and keeps reading zeroes.

    cp on the other hand copies it ok since it first stats the file and then mmaps the file.

    So my conclusion is that the bug is that sequential 'read' commands nevfer return EOF indicator.

    --- syscall log of vim opening the file ---
    open("/mnt/wiki/wikipedia-en/France.mw",O_RDONLY,00) = 3 (0x3)
    write(1,"\^[[1;43r\^[[27m\^[[m\^[[H\^[[2J"...,69) = 69 (0x45)
    mmap(0x0,1048576,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 877658112 (0x34500000)
    read(3,"{{about|the country}}\n{{pp-semi"...,8192) = 8192 (0x2000)
    select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
    read(3," power]] for many centuries. Dur"...,65536) = 65536 (0x10000)
    select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
    read(3,"urvived are [[Chinon (castle)|Ch"...,65536) = 65536 (0x10000)
    select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
    read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
    select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
    read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
    select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
    read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)
    select(1,{0},0x0,{0},{0.000000 }) = 0 (0x0)
    read(3,"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"...,65536) = 65536 (0x10000)

     
  • Yuri
    Yuri
    2009-04-11

    I did some more debugging, and found that in metadir.py read(self, path, size, offset) returns correct strings.
    Empty strings are returned after EOF has been reached.

     
  • I believe that I have the fix for this in my big patch of stuff that I'll be sending to the mailing list shortly.

    I will update this bug once that has been posted with a request for testing.

     
  • This should now be fixed in SVN.

    Please verify and update this bug report.

    Thank you.