(bug) vim freezes and loops forever (uses 100% CPU) in syntax.c

13 views
Skip to first unread message

Dominique Pelle

unread,
Dec 2, 2007, 8:18:59 AM12/2/07
to vim_dev
Hi

I can reproduce a vim bug filed in Ubuntu launchpad using the latest
vim-7.1 (Patches 1-166). Here is a link to the original bug description:

https://bugs.launchpad.net/ubuntu/+source/vim/+bug/68960

Here is how I can reproduce it. I did not use '-u NONE', because
standard plugins need to be loaded to reproduce that bug.
".vimrc" file only needs to contain "syntax on" to reproduce it:

$ cat ~/.vimrc
syntax on

$ vim +89 vim_testcase # file "vim_testcase" is attached

... then, when moving cursor around closing parentheses at
line 89, observe that vim freezes and takes 100% of CPU (it
can be interrupted with Ctrl-C).

Trying to debug, I found that vim loops forever in a while(...)
loop in syntax.c in function syntax_start():

syntax.c:

562 while (current_lnum < lnum)
563 {
...
...
596 load_current_state(prev);
...
...
609 line_breakcheck();
610 if (got_int)
611 {
612 current_lnum = lnum;
613 break;
614 }
615 }

This while loop never ends with attached "vim_testcase" file.
Adding some printf(), I can see that:

- Before entering above while loop:
- current_lnum == 65
- lnum == 80

- Then when iterating in the while loop:
- lnum remains unchanged (80)
- current_lnum becomes:

65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
etc.

current_lnum never reaches lnum (80) so loop never ends.

current_lnum goes back from 78 to 65 when calling
load_current_state(prev) at line 596.

I do not understand the idea behind load_current_state() and
store_current_state() to go beyond and come up with fix for this.

I'm using vim-7.1 (Patches 1-166) on Linux x86, built with
'configure --with-features=huge'.

-- Dominique

vim_testcase

Bram Moolenaar

unread,
Dec 2, 2007, 11:22:21 AM12/2/07
to Dominique Pelle, vim_dev

Dominique Pelle wrote:

I can reproduce it. Looks like a problem with the matchparen plugin
when getting a syntax ID, combined with the syntax stack being wrong.

This will be difficult to figure out, I'll put it in the todo list.

--
hundred-and-one symptoms of being an internet addict:
172. You join listservers just for the extra e-mail.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Reply all
Reply to author
Forward
0 new messages