When using %! item in 'statusline' option, Vim sometimes shows an error and sometimes crash.
vimrc.vim: set statusline=%!MyStatusLine() set laststatus=2 function MyStatusLine() return "" endfunction $ gvim -u vimrc.vim Error detected while processing function MyStatusLine: E121: Undefined variable: MyStatusLine Error detected while processing function MyStatusLine: E15: Invalid expression: MyStatusLine E15: Invalid expression: ~W^Iá3~L (message is random text) I am using GTK2 GUI. I saw the error at startup and when using scrollbar. The error can be reproduced by using :redraw! command in MyStatusLine(). function MyStatusLine() redraw! return "" endfunction It seems that: 1. build_stl_str_hl() w_p_stl is "%!MyStatusLine()". 2. eval_to_string() Evaluate "MyStatusLine()". 3. call_func() 8021 cc = name[len]; 8022 name[len] = NUL; At this time, name == w_p_stl + 2. Then w_p_stl is changed from "%!MyStatusLine()" to "%!MyStatusLine" 4. call_user_func() In this function, line_breakcheck() is invoked. Then Vim processes the GUI event loop. If there is an event which is cause of drawing, Vim draws statusline again. 5. build_stl_str_hl() At this time, w_p_stl is "%!MyStatusLine" by 3. call_func(). 6. eval_to_string() Evaluate "MyStatusLine" 7. get_var_tv() Echo error "E121: Undefined variable: MyStatusLine" 8. eval0() Echo error "E15: Invalid expression: MyStatusLine" 9. redraw_custum_statusline() 5907 if (called_emsg) 5908 set_string_option_direct((char_u *)"statusline", -1, 5909 (char_u *)"", OPT_FREE | (*wp->w_p_stl != NUL 5910 ? OPT_LOCAL : OPT_GLOBAL), SID_ERROR); Since error is raised, w_p_stl is freed. (back to first statusline drawing) 10. eval0() 3924 if (!aborting()) 3925 EMSG2(_(e_invexpr2), arg); Echo error "E15: Invalid expression: ~W^Iá3~L" At this time, arg == w_p_stl + 2. And w_p_stl is already freed. The following is an backtrace at 7. Breakpoint 1, get_var_tv (name=0x8216f02 "MyStatusLine", len=12, rettv=0xbfff961c, verbose=1) at eval.c:18349 18349 EMSG2(_(e_undefvar), name); (gdb) bt #0 get_var_tv (name=0x8216f02 "MyStatusLine", len=12, rettv=0xbfff961c, verbose=1) at eval.c:18349 #1 0x08076a9b in eval7 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1, want_string=0) at eval.c:5027 #2 0x08076367 in eval6 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1, want_string=0) at eval.c:4680 #3 0x08075f5d in eval5 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1) at eval.c:4496 #4 0x08075507 in eval4 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1) at eval.c:4191 #5 0x08075375 in eval3 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1) at eval.c:4103 #6 0x08075217 in eval2 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1) at eval.c:4032 #7 0x08075068 in eval1 (arg=0xbfff95b8, rettv=0xbfff961c, evaluate=1) at eval.c:3957 #8 0x08074fd3 in eval0 (arg=0x8216f02 "MyStatusLine", rettv=0xbfff961c, nextcmd=0x0, evaluate=1) at eval.c:3914 #9 0x08070e15 in eval_to_string (arg=0x8216f02 "MyStatusLine", nextcmd=0x0, convert=0) at eval.c:1296 #10 0x08070f5a in eval_to_string_safe (arg=0x8216f02 "MyStatusLine", nextcmd=0x0, use_sandbox=0) at eval.c:1340 #11 0x080577df in build_stl_str_hl (wp=0x8216fc8, out=0xbfffa36c "\364\257U", outlen=4096, fmt=0x8216f00 "%!MyStatusLine", use_sandbox=0, fillchar=32, maxwidth=81, hltab=0xbfffa0c0, tabtab=0xbfff9e40) at buffer.c:3415 #12 0x0815a857 in win_redr_custom (wp=0x8216fc8, draw_ruler=0) at screen.c:6101 #13 0x0815a367 in redraw_custum_statusline (wp=0x8216fc8) at screen.c:5906 #14 0x08159ebb in win_redr_status (wp=0x8216fc8) at screen.c:5775 #15 0x081515b5 in update_screen (type=40) at screen.c:529 #16 0x0819d68e in set_shellsize (width=0, height=0, mustset=0) at term.c:3161 #17 0x0819d4c6 in shell_resized () at term.c:3040 #18 0x081b19d3 in gui_resize_shell (pixel_width=587, pixel_height=663) at gui.c:1318 #19 0x081bf86a in form_configure_event (widget=0x833b808, event=0xbfffb8c0, data=0x0) at gui_gtk_x11.c:4002 #20 0x00bee474 in ?? () from /usr/lib/libgtk-x11-2.0.so.0 #21 0x00269072 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #22 0x0027e7a8 in ?? () from /usr/lib/libgobject-2.0.so.0 #23 0x0027f9b8 in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #24 0x0027ffb6 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #25 0x00d0a96e in ?? () from /usr/lib/libgtk-x11-2.0.so.0 #26 0x00be807c in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0 #27 0x081c4b26 in gtk_form_send_configure (form=0x833b808) at gui_gtk_f.c:905 #28 0x081c4052 in gtk_form_size_allocate (widget=0x833b808, allocation=0xbfffbcb0) at gui_gtk_f.c:519 #29 0x00276068 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #30 0x002676f9 in ?? () from /usr/lib/libgobject-2.0.so.0 #31 0x00268f98 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #32 0x0027e0b0 in ?? () from /usr/lib/libgobject-2.0.so.0 #33 0x0027fb2d in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #34 0x0027ffb6 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #35 0x00d125f0 in gtk_widget_size_allocate () from /usr/lib/libgtk-x11-2.0.so.0 #36 0x00b26c7f in ?? () from /usr/lib/libgtk-x11-2.0.so.0 #37 0x00276068 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #38 0x002676f9 in ?? () from /usr/lib/libgobject-2.0.so.0 #39 0x00268f98 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #40 0x0027e0b0 in ?? () from /usr/lib/libgobject-2.0.so.0 #41 0x0027fb2d in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #42 0x0027ffb6 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #43 0x00d125f0 in gtk_widget_size_allocate () from /usr/lib/libgtk-x11-2.0.so.0 #44 0x00d24deb in ?? () from /usr/lib/libgtk-x11-2.0.so.0 #45 0x00276068 in g_cclosure_marshal_VOID__BOXED () from /usr/lib/libgobject-2.0.so.0 #46 0x002676f9 in ?? () from /usr/lib/libgobject-2.0.so.0 #47 0x00269072 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #48 0x0027e0b0 in ?? () from /usr/lib/libgobject-2.0.so.0 #49 0x0027fb2d in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #50 0x0027ffb6 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #51 0x00d125f0 in gtk_widget_size_allocate () from /usr/lib/libgtk-x11-2.0.so.0 #52 0x00d25260 in ?? () from /usr/lib/libgtk-x11-2.0.so.0 #53 0x002769fc in g_cclosure_marshal_VOID__VOID () from /usr/lib/libgobject-2.0.so.0 #54 0x002676f9 in ?? () from /usr/lib/libgobject-2.0.so.0 #55 0x00269072 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0 #56 0x0027e49e in ?? () from /usr/lib/libgobject-2.0.so.0 #57 0x0027fb2d in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0 #58 0x0027ffb6 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0 #59 0x00b5a31a in gtk_container_check_resize () from /usr/lib/libgtk-x11-2.0.so.0 #60 0x00b5a370 in ?? () from /usr/lib/libgtk-x11-2.0.so.0 #61 0x00125f78 in ?? () from /usr/lib/libgdk-x11-2.0.so.0 #62 0x002d30f1 in ?? () from /lib/libglib-2.0.so.0 #63 0x002d4e78 in g_main_context_dispatch () from /lib/libglib-2.0.so.0 #64 0x002d8720 in ?? () from /lib/libglib-2.0.so.0 #65 0x002d8853 in g_main_context_iteration () from /lib/libglib-2.0.so.0 #66 0x00be8203 in gtk_main_iteration_do () from /usr/lib/libgtk-x11-2.0.so.0 #67 0x081c217c in gui_mch_update () at gui_gtk_x11.c:6473 #68 0x081a0b4f in ui_breakcheck () at ui.c:364 #69 0x08103dc7 in line_breakcheck () at misc1.c:8423 #70 0x0808d2a1 in call_user_func (fp=0x82881a8, argcount=0, argvars=0xbfffcee8, rettv=0xbfffd40c, firstline=1, lastline=1, selfdict=0x0) at eval.c:21096 #71 0x0807a81d in call_func (name=0x8216f02 "MyStatusLine", len=12, rettv=0xbfffd40c, argcount=0, argvars=0xbfffcee8, firstline=1, lastline=1, doesrange=0xbfffd078, evaluate=1, selfdict=0x0) at eval.c:8115 #72 0x0807a471 in get_func_tv (name=0x8216f02 "MyStatusLine", len=12, rettv=0xbfffd40c, arg=0xbfffd3a8, firstline=1, lastline=1, doesrange=0xbfffd078, evaluate=1, selfdict=0x0) at eval.c:7961 #73 0x08076a4e in eval7 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1, want_string=0) at eval.c:5013 #74 0x08076367 in eval6 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1, want_string=0) at eval.c:4680 #75 0x08075f5d in eval5 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1) at eval.c:4496 #76 0x08075507 in eval4 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1) at eval.c:4191 #77 0x08075375 in eval3 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1) at eval.c:4103 #78 0x08075217 in eval2 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1) at eval.c:4032 #79 0x08075068 in eval1 (arg=0xbfffd3a8, rettv=0xbfffd40c, evaluate=1) at eval.c:3957 #80 0x08074fd3 in eval0 (arg=0x8216f02 "MyStatusLine", rettv=0xbfffd40c, nextcmd=0x0, evaluate=1) at eval.c:3914 #81 0x08070e15 in eval_to_string (arg=0x8216f02 "MyStatusLine", nextcmd=0x0, convert=0) at eval.c:1296 #82 0x08070f5a in eval_to_string_safe (arg=0x8216f02 "MyStatusLine", nextcmd=0x0, use_sandbox=0) at eval.c:1340 #83 0x080577df in build_stl_str_hl (wp=0x8216fc8, out=0xbfffe15c "?P\a\b\034aH\b\360\341\377\277\003", outlen=4096, fmt=0x8216f00 "%!MyStatusLine", use_sandbox=0, fillchar=32, maxwidth=81, hltab=0xbfffdeb0, tabtab=0xbfffdc30) at buffer.c:3415 #84 0x0815a857 in win_redr_custom (wp=0x8216fc8, draw_ruler=0) at screen.c:6101 #85 0x0815a367 in redraw_custum_statusline (wp=0x8216fc8) at screen.c:5906 #86 0x0815f96b in showruler (always=0) at screen.c:9468 #87 0x080dd6b2 in main_loop (cmdwin=0, noexmode=0) at main.c:1147 #88 0x080dd281 in main (argc=3, argv=0xbffff434) at main.c:942 -- Yukihiro Nakadaira - yukihiro.nakada...@gmail.com --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---