Thursday, January 21, 2010

Re: vim reproducible crash, with backtrace report

Hi,

I believe we found the condition to crash vim:

---------------------------------------------------
while 1
inoremap <expr><Plug>VimimChineseMode <SID>VimimChineseMode()
endwhile
---------------------------------------------------

Note: the condition is that <Plug> name is not in consistence with
<SID> name. (ie, no <SID>ChineseMode() function available).

After reading doc on <Plug>, I found naming of both has to be in sync.

However, for normal case, it seems perfect okay to do something like:
---------------------------------------------------
while 1
imap <C-Bslash> <Left>
endwhile
---------------------------------------------------


PS: comparison:

(1) The crashing function when running multiple times:

" -----------------------------------------
function! s:vimim_chinese_mode_mapping_on()
" -----------------------------------------
inoremap <expr><Plug>VimimChineseMode <SID>VimimChineseMode()
imap <C-Bslash> <Plug>VimimChineseMode
endfunction


(2) The fixed version:

" -----------------------------------------
function! s:vimim_chinese_mode_mapping_on()
" -----------------------------------------
inoremap <unique> <expr> <Plug>VimimChinesemode <SID>Chinesemode()
imap <C-Bslash> <Plug>VimimChinesemode
endfunction

No comments: