If input ':' after "set history=100000000", OS get stuck or Vim can't quit by ':q' after E342.

94 views
Skip to first unread message

h_east

unread,
Jun 24, 2014, 12:09:36 PM6/24/14
to vim...@googlegroups.com
Hi Bram and Vim developers,

How to reproduce:
- start Vim and set 'hi' option to huge value.
$ vim -N -u NONE -c "set history=100000000"
- Input colon.
:

Occurred pattern #1
- OS get stuck (Verrry slow response)

Occurred pattern #2
- get 'E342'
E342: Out of memory! (allocating 1600000000 bytes)
- And Vim can not terminated by ':q'.
(I know terminated ZQ or ZZ)


Investigation for #1
- `:` typed after 'hi'option changed, call init_history().
This function is call lalloc() by huge value.
(p_hi * 16 = 1600000000)
I think we should have an upper limit to 'hi'. (10000 in Patch#1)

Investigation for #2
- If an error occurs after I press the colon, The command line
is not interpreted in the usual way.
[ea.skip ... ex_docmd.c:1972]
So, if get an error in init_history() and command-line
character is `:`, Then I clear the did_emsg.


I attached two patches.
Please check these.

Thank you for reading my crazy English :-)
--
Best regards,
Hirohito Higashi

set_history_1.patch
set_history_2.patch

Bram Moolenaar

unread,
Jun 25, 2014, 6:06:06 AM6/25/14
to h_east, vim...@googlegroups.com
Thanks. Yeah, this code was written with a small number of history
entries in mind. I think your solution is good enough.

While at it, let's increase the default value from 20 to 50.

Not being able to exit because of an error is a problem as well.
Thanks for fixing that too. However, there might be other causes for an
error message, and we don't want any of them to cause a problem.
Thus let's just reset did_emsg before the user starts typing.

> Thank you for reading my crazy English :-)

It's not too bad.


--
This is the polymorph virus! Follow these instructions carefully:
1. Send this message to everybody you know.
2. Format your harddisk.
Thank you for your cooperation in spreading the most powerful virus ever!

/// 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 ///
Reply all
Reply to author
Forward
0 new messages