A way to crash vim with setloclist()

98 views
Skip to first unread message

Marcin Szamotulski

unread,
Oct 28, 2012, 11:15:19 AM10/28/12
to Vim Dev
Hello Vim Dev,

Here is a way to crash vim (vim -u NONE --noplugin).

Set an autocommand:

au BufUnload * :call setloclist(0, [{'bufnr':1, 'lnum':1, 'col':1, 'text': 'tango down'}])

Now run:

:lvimgrep /.*/ *.txt

And vim goes down. Should lvimgrep trigger BufUnload autocommands? Where it is useful?

Best,
Marcin

Bram Moolenaar

unread,
Oct 28, 2012, 3:12:47 PM10/28/12
to Marcin Szamotulski, Vim Dev

Marcin Szamotulski wrote:

> Here is a way to crash vim (vim -u NONE --noplugin).
>
> Set an autocommand:
>
> au BufUnload * :call setloclist(0, [{'bufnr':1, 'lnum':1, 'col':1, 'text': 'tango down'}])
>
> Now run:
>
> :lvimgrep /.*/ *.txt
>
> And vim goes down.

I can reproduce it.

> Should lvimgrep trigger BufUnload autocommands? Where it is useful?

Vimgrep works by loading the file into a buffer. That triggers
autocommands to be able to search in compressed files and handles
encoding conversions. BufUnload may be needed to undo the effect of
BufRead autocommands.

I'll put this on the todo list, but it's unlikely that I will be able to
fix it soon. I hope someone can make a patch.

--
The goal of science is to build better mousetraps.
The goal of nature is to build better mice.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Nov 1, 2012, 6:21:50 PM11/1/12
to Vim Dev
Hi Bram!

On So, 28 Okt 2012, Bram Moolenaar wrote:

>
> Marcin Szamotulski wrote:
>
> > Here is a way to crash vim (vim -u NONE --noplugin).
> >
> > Set an autocommand:
> >
> > au BufUnload * :call setloclist(0, [{'bufnr':1, 'lnum':1, 'col':1, 'text': 'tango down'}])
> >
> > Now run:
> >
> > :lvimgrep /.*/ *.txt
> >
> > And vim goes down.
>
> I can reproduce it.
>
> > Should lvimgrep trigger BufUnload autocommands? Where it is useful?
>
> Vimgrep works by loading the file into a buffer. That triggers
> autocommands to be able to search in compressed files and handles
> encoding conversions. BufUnload may be needed to undo the effect of
> BufRead autocommands.
>
> I'll put this on the todo list, but it's unlikely that I will be able to
> fix it soon. I hope someone can make a patch.

Here is a patch including a test.

regards,
Christian
vimgrep_crash.diff

Bram Moolenaar

unread,
Nov 2, 2012, 5:58:50 AM11/2/12
to Christian Brabandt, Vim Dev
Great, thanks.


--
"How is your new girlfriend?"
"90-60-90 man!"
"What, pale purple?"

Marcin Szamotulski

unread,
Nov 2, 2012, 7:38:09 AM11/2/12
to vim...@googlegroups.com
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

The patch is working here.

Thanks,
Marcin
Reply all
Reply to author
Forward
0 new messages