Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set history=100000000と設定するとコマンドラインモードに移行する度にE342が表示されVimを終了出来ない #579

Closed
h-east opened this issue Jun 17, 2014 · 17 comments

Comments

@h-east
Copy link
Member

h-east commented Jun 17, 2014

https://twitter.com/p_ck_/status/478875647628951552

vim -u NONE -c 'set history=100000000'
とかやると、E342を吐いて死ぬ

E342: メモリが足りません! (1600000000 バイトを割当要求)

Fedora19で試したところ死にはしませんでしたが:押下直後にE342が表示されてその後に入力したコマンドがexコマンドとして認識されていないようでした。
Windows 7でもちょっと待たされますが現象は同じでした。

init_history()lalloc()がNULLを返してE342を出力した後のどこかでマズっている感じ。

暫定対策:
ZQまたはZZでVimを終了させる。

@h-east
Copy link
Member Author

h-east commented Jun 17, 2014

:qが正しく処理されば以下のような流れでex_quit()が呼ばれる。

#0  ex_quit (eap=0x7fff758f7ec0) at ex_docmd.c:6549
#1  0x000000000046f7e2 in do_one_cmd (cmdlinep=0x7fff758f8538, sourcing=0,
    cstack=0x7fff758f8090, fgetline=0x484c83 <getexline>, cookie=0x0)
    at ex_docmd.c:2701
#2  0x000000000046cde9 in do_cmdline (cmdline=0x0, fgetline=
    0x484c83 <getexline>, cookie=0x0, flags=0) at ex_docmd.c:1126
#3  0x00000000004f9ccb in nv_colon (cap=0x7fff758f8660) at normal.c:5308
#4  0x00000000004f2800 in normal_cmd (oap=0x7fff758f8730, toplevel=1)
    at normal.c:1156
#5  0x00000000005e6a22 in main_loop (cmdwin=0, noexmode=0) at main.c:1326
#6  0x00000000005e637f in main (argc=4, argv=0x7fff758f8a68) at main.c:1026

だがE342が発生すると:qを入力してもex_quit()が呼ばれない。

@koron
Copy link
Member

koron commented Jun 17, 2014

historyに設定できる値に上限を設けたほうが手っ取り早くないですか?

@koron
Copy link
Member

koron commented Jun 17, 2014

もしかしたら32bit版使うと即死?

@rhysd
Copy link

rhysd commented Jun 17, 2014

set history=100000000

こんな設定している人ほとんど見ないですが,どういう需要があるんでしょうか…

@Shougo
Copy link
Member

Shougo commented Jun 17, 2014

おそらく、「ほぼ無限に全ての履歴を保存したい」んでしょう。zshではそういう設定をしている人を見たことがあります。

@h-east
Copy link
Member Author

h-east commented Jun 18, 2014

historyに設定できる値に上限を設けたほうが手っ取り早くないですか?

上限を設けてもアカンときはアカンのとちゃいます?反対はしません。
それとは別に、エラー後の処理がおかしくて:qが効かないのを直したいです。


これ落ちた人います?

@h-east
Copy link
Member Author

h-east commented Jun 20, 2014

これで:入力後にE342出てもq押してENTER押せば終了できる。
んだけど、historyに設定する値によってはLinuxでも数十秒引き込まれてしまうね。(killするのもカクカクw)
やっぱり上限を設けましょう!:smile:

diff -r 4aa63564dd3f src/ex_getln.c
--- a/src/ex_getln.c    Wed Jun 18 21:38:18 2014 +0200
+++ b/src/ex_getln.c    Sat Jun 21 00:36:12 2014 +0900
@@ -334,6 +334,9 @@

 #ifdef FEAT_CMDHIST
     init_history();
+    if (firstc == ':')
+   did_emsg = 0;       /* When error occured in init_history(),
+                  But We can execute ':q'. */
     hiscnt = hislen;       /* set hiscnt to impossible history value */
     histype = hist_char2type(firstc);
 #endif

@h-east
Copy link
Member Author

h-east commented Jun 24, 2014

'history'オプションに上限を設けるpatch (10000が最大)

diff -r 4aa63564dd3f runtime/doc/options.txt
--- a/runtime/doc/options.txt   Wed Jun 18 21:38:18 2014 +0200
+++ b/runtime/doc/options.txt   Tue Jun 24 23:09:29 2014 +0900
@@ -3926,6 +3926,7 @@
    A history of ":" commands, and a history of previous search patterns
    are remembered.  This option decides how many entries may be stored in
    each of these histories (see |cmdline-editing|).
+   The maximum value is 10000.
    NOTE: This option is set to the Vi default value when 'compatible' is
    set and to the Vim default value when 'compatible' is reset.

diff -r 4aa63564dd3f src/option.c
--- a/src/option.c  Wed Jun 18 21:38:18 2014 +0200
+++ b/src/option.c  Tue Jun 24 23:09:29 2014 +0900
@@ -8595,6 +8595,11 @@
    errmsg = e_positive;
    p_hi = 0;
     }
+    else if (p_hi > 10000)
+    {
+   errmsg = e_invarg;
+   p_hi = 10000;
+    }
     if (p_re < 0 || p_re > 2)
     {
    errmsg = e_invarg;

@h-east
Copy link
Member Author

h-east commented Jun 24, 2014

patch 2つvim_devに投げた。
https://groups.google.com/d/msg/vim_dev/cxvBwnSaWrY/5mbWiAFIdn8J

@rhysd
Copy link

rhysd commented Jun 24, 2014

🐶 👍

@h-east
Copy link
Member Author

h-east commented Jun 25, 2014

'history'オプションに上限が設けられて最大10000になったぜ!Yeah:cat2:
Patch 7.4.336
https://groups.google.com/d/msg/vim_dev/og12S0uF8QI/U3_oZAeXDDwJ

@h-east
Copy link
Member Author

h-east commented Jun 25, 2014

デフォルト値も 20 から 50 に変更になりました。
E342が出たら:qで終われない件は無理やりやってる感があって他に影響するかもしれないのでやめときます。(Bram氏もそう言ってる)
ということでIssueは閉じます。
誰か p_ck_ さんに伝えて下さい:smile:

@h-east
Copy link
Member Author

h-east commented Jun 25, 2014

回答を読み違えていたw
E342が出ても:qで終わらせられるようにするpatchも入った!(ちょっと変更入ったけど)
Patch 7.4.337
https://groups.google.com/d/msg/vim_dev/wYmZK_COpdo/JsbpQelIrUwJ

@mattn
Copy link
Member

mattn commented Jun 25, 2014

Bram「お前の英語、狂っちゃいないぜ」

@mattn
Copy link
Member

mattn commented Jun 27, 2014

続報

「なんで 10000 なんだ。俺は 65536 を設定してる。」という意見も。

@koron
Copy link
Member

koron commented Jun 27, 2014

くっそw

@h-east
Copy link
Member Author

h-east commented Jun 27, 2014

set viminfo+=:100000000
set viminfo?
  viminfo='100,<50,s10,h,rA:,rB:,:100000000

「まさか!?viminfoオプションって設定値青天井なのか?」
と思って調べたら参照時にちゃんと最大値(今は10000)に丸め込んでました。
(write_viminfo_history()get_viminfo_parameter()を呼んだ後の10行くらい)

「そのまさかじゃなかった!フハハハハハ!」

viminfoオプション設定時にエラー出せばいいのにと思った。めんどいのかな?

@h-east h-east self-assigned this Jun 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants