Bug? Some problems with Vim7.3 with Lusty-explorer plugin

2010-09-11 Fir de Conversatie lilydjwg
I've been using vim7.3 for some time, and find some problem with its
ruby support.

1. $curbuf.number always returns 0 on my platform. See this thread for
   more infomation
   https://groups.google.com/group/vim_use/browse_thread/thread/a122376e8dbc6d29
   Later I modified Lusty-explorer to not use the variable.

2. When I am using Lusty-explorer with +perl and +ruby compiled in,
   Vim usually crashes. Terminal output:
 Vim: 拦截到致命信号(deadly signal) SEGV
 Vim: 结束。
 zsh: segmentation fault  vim
  gdb backtrace when this happens:
#0  __memset_sse2 () at ../sysdeps/i386/i686/multiarch/memset-sse2.S:160
#1  0x00d1d6ac in Perl_sv_upgrade () from /usr/lib/libperl.so.5.10
#2  0x00d1ea6a in Perl_sv_magicext () from /usr/lib/libperl.so.5.10
#3  0x00d1fc11 in Perl_sv_magic () from /usr/lib/libperl.so.5.10
#4  0x00d21882 in Perl_sv_setiv () from /usr/lib/libperl.so.5.10
#5  0x08203691 in perl_buf_free (bp=0x847b890) at if_perl.xs:638
#6  0x080742e3 in free_buffer (buf=0x847b890) at buffer.c:613
#7  0x08073fec in close_buffer (win=0x0, buf=0x847b890, action=4)
at buffer.c:468
#8  0x08074de8 in do_buffer (action=4, start=0, dir=1, count=0, forceit=1)
at buffer.c:1136
#9  0x0807465e in do_bufdel (command=4, arg=0x84b8aa1 , addr_count=0,
start_bnr=12, end_bnr=1, forceit=1) at buffer.c:834
#10 0x080cbb2c in ex_bunload (eap=0xbfff9f8c) at ex_docmd.c:4939
#11 0x080c817d in do_one_cmd (cmdlinep=0xbfffa140, sourcing=1,
cstack=0xbfffa148, fgetline=0, cookie=0x0) at ex_docmd.c:2656
#12 0x080c5a56 in do_cmdline (cmdline=0x837c2d0 bwipeout!, getline=0,
cookie=0x0, flags=11) at ex_docmd.c:1122
#13 0x080c5110 in do_cmdline_cmd (cmd=0x837c2d0 bwipeout!) at 
ex_docmd.c:728
#14 0x0820cf98 in vim_command (self=3084803600, str=3084486540) at 
if_ruby.c:731
#15 0x010619a3 in ?? () from /usr/lib/libruby1.8.so.1.8
---Type return to continue, or q return to quit---
  
  I think I have no plugin that uses perl.

3. swapfile name and backup file name changes to 8.3 style after
   invoking :LustyBufferExplorer. Here's how to reproduce it:

* Open a file, eg Contents. The swapfile's name will be .Contents.swp
* open another file
* use Lusty-Explorer to switch to the previous file
* use :sw to see the swapfile's name, it becomes Contents.swp
* For longer file names, Vim will truncate it to 8.3 style

  The backup file name changes the same way.

4. I tried Lusty-explorer on Windows XP with ruby1.9 (I got the
   gvim7.3 for vim.org . Vim crashes immediately when I invoke
   Lusty-explorer.

I hope these problems can be solved soon. I really love vim7.3.

PS:

Except the last problem, they happens on Ubuntu10.10 and Archlinux.

my Vim :version:

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 31 2010 12:55:01)
编译者 lilyd...@lilydjwg-desktop
巨型版本 带 GTK2-GNOME 图形界面。  可使用(+)与不可使用(-)的功能:
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +gettext 
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall 
+linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname 
+mouse +mouseshape +mouse_dec -mouse_gpm -mouse_jsbterm +mouse_netterm 
-mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme -netbeans_intg 
-osfiletype +path_extra -perl +persistent_undo +postscript +printer +profile 
+python -python3 +quickfix +reltime +rightleft +ruby +scrollbind +signs 
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim 
+xsmp_interact +xterm_clipboard -xterm_save 
 系统 vimrc 文件: $VIM/vimrc
 用户 vimrc 文件: $HOME/.vimrc
  用户 exrc 文件: $HOME/.exrc
系统 gvimrc 文件: $VIM/gvimrc
用户 gvimrc 文件: $HOME/.gvimrc
系统菜单文件: $VIMRUNTIME/menu.vim
 $VIM 预设值: /usr/local/share/vim
编译方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -D_REENTRANT 
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ 
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 
-I/usr/include/freetype2 -I/usr/include/directfb -I/usr/include/libpng12   
-DORBIT2=1 -pthread -D_REENTRANT -I/usr/include/libgnomeui-2.0 
-I/usr/include/libart-2.0 -I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1 
-I/usr/include/libgnome-2.0 -I/usr/include/libbonoboui-2.0 
-I/usr/include/libgnomecanvas-2.0 -I/usr/include/gtk-2.0 

Re: Suggest ':TOhtml' to use 'fileencoding' rather than 'encoding' as default html charset

2010-09-11 Fir de Conversatie Ben Fritz


On Sep 10, 10:22 pm, Benjamin Fritz fritzophre...@gmail.com wrote:
 Unfortunately, I could not find a list of widely supported charsets,
 so I just used all the ones in Vim and the IANA registry, as mentioned
 previously. If there is such a list, would it be a good idea to limit
 the automatically detected charsets to those in the list? Along those
 lines, it could be a good idea to automatically use UTF-8 in place of
 UTF-16 and UTF-32. Currently these charsets are selected as-is.


Notably, I should mention:

UTF-32 is not supported at all in Opera. In fact, they removed support
for UTF-32 in version 10: http://www.opera.com/docs/changelogs/windows/1000b1/

UTF-32 and UTF-16 do not seem to be supported by Firefox at all for
xhtml, and I had to manually select the correct encoding for the html
documents.

Google Chrome, Internet Explorer 8, and Safari seem to have no
problems (although IE8 does not support xhtml at all so I could not
test these in that browser).

I'm thinking that I will make the automatic detection from the Vim
encoding default to UTF-8 for these encodings, but will leave the
detection of encoding from charset in case the user specifies one of
them using g:html_use_encoding. The user can also use
g:html_charset_override if they want these to be automatically
detected.

Thoughts? There are some test files available here if you're curious:

http://code.google.com/p/vim-2html-test/source/browse/encoding_test/

-- 
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


Re: 2html.vim causes Vim to crash with a SIGSEGV?!

2010-09-11 Fir de Conversatie Carlo
On Sep 5, 3:33 am, Peter Odding pe...@peterodding.com wrote:

 The regex is a 77 KB monstrosity that's supposed to match a predefined
 set of strings in 2html.vim output and is complicated by the fact that
 it also matches strings with embedded HTML tags. The regex is corrupt
 because of a bug in my plug-in; I forgot to escape special characters
 like [.

I can reproduce this crash with a much simpler, valid, regex:

$ vim -Ngfu NONE --noplugin -c execute '/' . repeat('a\|', 9000) .
'a'
Vim: Caught deadly signal SEGV

On my machine, it crashes with 9000 but not with 8000 repetitions.

 I'm also attaching a backtrace from GDB and the output of Valgrind,
 which tell me that Vim crashes because of a NULL pointer dereference at
 regexp.c:4730 in the latest Vim 7.3 source. I've tried reasoning about
 this but regmatch() is far too complex for my comprehension at the
 moment :-)

My backtrace is exactly the same:

(gdb) bt
#0  0x0055a545 in regmatch (scan=0x953cba \003) at regexp.c:
4730
#1  0x00557dd5 in regtry (prog=0x953ca0, col=0) at regexp.c:
3711
#2  0x00557b9c in vim_regexec_both (line=0xabe7c0 , col=0,
tm=0x0) at regexp.c:3600
#3  0x005574c7 in vim_regexec (rmp=0x7fffdd00,
line=0xabe7c0 , col=0) at regexp.c:3347
#4  0x004b85cd in match_file_pat (pattern=0x0, prog=0x953ca0,
fname=0xabe7c0 , sfname=0x0, tail=
0xabe7c0 , allow_dirs=0) at fileio.c:10003
#5  0x004b7bd2 in auto_next_pat (apc=0x7fffde50,
stop_at_last=0) at fileio.c:9525
#6  0x004b77d8 in apply_autocmds_group (event=EVENT_VIMENTER,
fname=0xabe7c0 , fname_io=0x0, force=0,
group=-3, buf=0x88c150, eap=0x0) at fileio.c:9358
#7  0x004b7108 in apply_autocmds (event=EVENT_VIMENTER,
fname=0x0, fname_io=0x0, force=0, buf=0x88c150)
at fileio.c:8994
#8  0x004d3973 in main (argc=6, argv=0x7fffe1e8) at main.c:
903

Carlo

(I attempted to post this message earlier but it somehow didn't make
it through)


   - Peter Odding

 [crash.vim5K ]function! s:VimCrashOnRegexEval(tags)
   let patterns = []
   let short = s:IgnoreHTML('s') . s:IgnoreHTML(':')
   let long = s:IgnoreHTML('lt;') . s:IgnoreHTML('[Ss][Ii][Dd]') . 
 s:IgnoreHTML('gt;')
   let prefix = '\%(' . short . '\|' . long . '\)'
   for name in a:tags
     let tokens = [prefix]
     for token in split(name, '\...@=\|\W\@=')
        The bug in my original code was that I didn't escape special pattern 
 characters in
        {token} before adding it to {tokens}, but that doesn't mean Vim 
 should crash :-(
       call add(tokens, s:IgnoreHTML(token))
     endfor
     call add(patterns, join(tokens, ''))
   endfor
   execute '/' . escape(join(patterns, '\|'), '~/')
 endfunction

 function! s:IgnoreHTML(s)
   return printf('\%%([^/][^]*%s/[^]\+\|%s\)', a:s, a:s)
 endfunction

 call s:VimCrashOnRegexEval(['s:msg', 'g:loaded_publish', 'foreach_window', 
 's:ei_save',
  \ 's:loaded_scripts', 'tex_fold_enabled', 'g:timer_verbosity', 'Tab', 
 'reload_colors',
  \ 'b:luainspect_syntax_error', 'g:easytags_resolve_links', 's:hif_save', 
 'unresolve_scriptname',
  \ 'g:easytags_always_enabled', 'Home', 'session#get_names', 's:directory', 
 'session#save_cmd',
  \ 's:stal_save', 'session#auto_dirty_check', 'persist_special_windows', 
 'C-Down',
  \ 'b:luainspect_input', 'ignore_html', 's:ctags_filetypes', 
 'session#close_cmd', 's:object_methods',
  \ 'xolox#timer#stop', 'easytags#highlight', 'g:session_autoload', 
 'g:publish_omit_dothtml',
  \ 'save_plugin_window', 'netrw_hide', 'prep_cmdline', 's:cached_contents', 
 'g:lua_inspect_internal',
  \ 'java_allow_cpp_keywords', 'open_at_cursor', 'luainspect#make_request', 
 'library_call',
  \ 'xolox#debug', 'publish#run_rsync', 'easytags#get_tagsfile', 's:script', 
 'session#auto_load',
  \ 'g:reload_on_write', 'easytags#read_tagsfile', 'publish#html_encode', 
 'Left', 's:tagged_files',
  \ 'easytags#update', 'xolox#path#absolute', 'easytags#map_filetypes', 
 'rename_variable',
  \ 'publish#rsync_check', 'tex_flavor', 'Right', 's:lock_files', 
 's:library_version', 'F11',
  \ 'g:html_ignore_folding', 's:has_reltime', 'g:html_number_lines', 
 'g:easytags_on_cursorhold',
  \ 'save_qflist', 'g:easytags_autorecurse', 'find_tagged_files', 
 's:changed_path', 's:enoimpl',
  \ 'escape_tags', 'g:loaded_session', 'xolox#timer#start', 'get_name', 
 'g:easytags_ignored_filetypes',
  \ 'xolox#shell#open_cmd', 'xolox#quote_pattern', 'xolox#shell#execute', 
 'convert_value',
  \ 'xolox#unique', 'session#path_to_name', 'Esc[A', 'session#open_cmd', 
 'python_highlight_all',
  \ 'A-Right', 's:files_to_publish', 'define_default_styles', 
 's:supported_filetypes',
  \ 'xolox#option#join', 's:loclist_to_window', 'session#delete_cmd', 
 'Esc[23~', 'session#save_state',
  \ 'Del', 'vimsyn_noerror', 'publish#find_tags', 'reload_indent', 
 'xolox#shell#open_with',
  \ 's:cached_filenames', 'xolox#reload#script', 'g:easytags_ctags_version', 
 'g:html_use_css',
  \ 'clear_previous_matches', 

Re: 2html.vim causes Vim to crash with a SIGSEGV?!

2010-09-11 Fir de Conversatie ZyX
Ответ на сообщение «Re: 2html.vim causes Vim to crash with a SIGSEGV?!», 
присланное в 20:09:39 11 сентября 2010, Суббота,
отправитель Carlo:

Confirmed, but before crashing it prints
Error detected while processing command line:
E339: Pattern too long
Command:
LANG=C vim -u NONE -c 'execute ''/''.repeat(''a\|'', 9000)'
(removed unneeded options). In the help file it is mentioned that 
this error may occur only on systems with 16 bit ints:
This only happens on systems with 16 bit ints: The compiled regexp pattern 
is
longer than about 65000 characters.  Try using a shorter pattern.
  (message.txt, line 
484)
And vim obviously should not crash.

Текст сообщения:
 On Sep 5, 3:33 am, Peter Odding pe...@peterodding.com wrote:
  The regex is a 77 KB monstrosity that's supposed to match a predefined
  set of strings in 2html.vim output and is complicated by the fact that
  it also matches strings with embedded HTML tags. The regex is corrupt
  because of a bug in my plug-in; I forgot to escape special characters
  like [.
 
 I can reproduce this crash with a much simpler, valid, regex:
 
 $ vim -Ngfu NONE --noplugin -c execute '/' . repeat('a\|', 9000) .
 'a'
 Vim: Caught deadly signal SEGV
 
 On my machine, it crashes with 9000 but not with 8000 repetitions.
 
  I'm also attaching a backtrace from GDB and the output of Valgrind,
  which tell me that Vim crashes because of a NULL pointer dereference at
  regexp.c:4730 in the latest Vim 7.3 source. I've tried reasoning about
  this but regmatch() is far too complex for my comprehension at the
  moment :-)
 
 My backtrace is exactly the same:
 
 (gdb) bt
 #0  0x0055a545 in regmatch (scan=0x953cba \003) at regexp.c:
 4730
 #1  0x00557dd5 in regtry (prog=0x953ca0, col=0) at regexp.c:
 3711
 #2  0x00557b9c in vim_regexec_both (line=0xabe7c0 , col=0,
 tm=0x0) at regexp.c:3600
 #3  0x005574c7 in vim_regexec (rmp=0x7fffdd00,
 line=0xabe7c0 , col=0) at regexp.c:3347
 #4  0x004b85cd in match_file_pat (pattern=0x0, prog=0x953ca0,
 fname=0xabe7c0 , sfname=0x0, tail=
 0xabe7c0 , allow_dirs=0) at fileio.c:10003
 #5  0x004b7bd2 in auto_next_pat (apc=0x7fffde50,
 stop_at_last=0) at fileio.c:9525
 #6  0x004b77d8 in apply_autocmds_group (event=EVENT_VIMENTER,
 fname=0xabe7c0 , fname_io=0x0, force=0,
 group=-3, buf=0x88c150, eap=0x0) at fileio.c:9358
 #7  0x004b7108 in apply_autocmds (event=EVENT_VIMENTER,
 fname=0x0, fname_io=0x0, force=0, buf=0x88c150)
 at fileio.c:8994
 #8  0x004d3973 in main (argc=6, argv=0x7fffe1e8) at main.c:
 903
 
 Carlo
 
 (I attempted to post this message earlier but it somehow didn't make
 it through)
 
- Peter Odding
  
  [crash.vim5K ]function! s:VimCrashOnRegexEval(tags)
let patterns = []
let short = s:IgnoreHTML('s') . s:IgnoreHTML(':')
let long = s:IgnoreHTML('lt;') . s:IgnoreHTML('[Ss][Ii][Dd]') .
  s:IgnoreHTML('gt;') let prefix = '\%(' . short . '\|' . long . '\)'
for name in a:tags
  let tokens = [prefix]
  for token in split(name, '\...@=\|\W\@=')
 The bug in my original code was that I didn't escape special
  pattern characters in  {token} before adding it to {tokens}, but that
  doesn't mean Vim should crash :-( call add(tokens, s:IgnoreHTML(token))
  endfor
  call add(patterns, join(tokens, ''))
endfor
execute '/' . escape(join(patterns, '\|'), '~/')
  endfunction
  
  function! s:IgnoreHTML(s)
return printf('\%%([^/][^]*%s/[^]\+\|%s\)', a:s, a:s)
  endfunction
  
  call s:VimCrashOnRegexEval(['s:msg', 'g:loaded_publish',
  'foreach_window', 's:ei_save', \ 's:loaded_scripts', 'tex_fold_enabled',
  'g:timer_verbosity', 'Tab', 'reload_colors', \
  'b:luainspect_syntax_error', 'g:easytags_resolve_links', 's:hif_save',
  'unresolve_scriptname', \ 'g:easytags_always_enabled', 'Home',
  'session#get_names', 's:directory', 'session#save_cmd', \ 's:stal_save',
  'session#auto_dirty_check', 'persist_special_windows', 'C-Down', \
  'b:luainspect_input', 'ignore_html', 's:ctags_filetypes',
  'session#close_cmd', 's:object_methods', \ 'xolox#timer#stop',
  'easytags#highlight', 'g:session_autoload', 'g:publish_omit_dothtml', \
  'save_plugin_window', 'netrw_hide', 'prep_cmdline', 's:cached_contents',
  'g:lua_inspect_internal', \ 'java_allow_cpp_keywords', 'open_at_cursor',
  'luainspect#make_request', 'library_call', \ 'xolox#debug',
  'publish#run_rsync', 'easytags#get_tagsfile', 's:script',
  'session#auto_load', \ 'g:reload_on_write', 'easytags#read_tagsfile',
  'publish#html_encode', 'Left', 's:tagged_files', \ 'easytags#update',
  'xolox#path#absolute', 'easytags#map_filetypes', 'rename_variable', \
  'publish#rsync_check', 'tex_flavor', 'Right', 's:lock_files',
  's:library_version', 'F11', \ 'g:html_ignore_folding',
  's:has_reltime', 'g:html_number_lines', 'g:easytags_on_cursorhold', \
  'save_qflist', 

Re: 2html.vim causes Vim to crash with a SIGSEGV?!

2010-09-11 Fir de Conversatie Carlo
I believe I've got a patch for this (see below).

First, if you look at the stacktrace in some detail in gdb, you'll see
that this error occurs while matching regexp .* against the current
filename ( in this case) during autocmd execution. The crash occurs
because in line 4730, 'next' is null. In line 3888, 'next' is the
result of calling regnext(). regnext() returns NULL because global
variable reg_toolong is TRUE. But of course the pattern .* is not
too long - instead, this is left over from the evaluation of the
previous very long regexp (a\|a\|a...).

This confusion occurs because regnext() is used both in compilation
and evaluation of regexes. Its behaviour of returning NULL if
reg_toolong is TRUE really only makes sense during compilation. The
easiest way to fix it is to just set reg_toolong to FALSE before
starting regexp evaluation, as in my patch. (It can only ever be set
to TRUE during the compilation phase.)

Carlo


diff --git a/src/regexp.c b/src/regexp.c
--- a/src/regexp.c
+++ b/src/regexp.c
@@ -3339,6 +3339,7 @@ vim_regexec(rmp, line, col)
 reg_maxline = 0;
 reg_line_lbr = FALSE;
 reg_win = NULL;
+reg_toolong = FALSE;
 ireg_ic = rmp-rm_ic;
 #ifdef FEAT_MBYTE
 ireg_icombine = FALSE;
@@ -3363,6 +3364,7 @@ vim_regexec_nl(rmp, line, col)
 reg_maxline = 0;
 reg_line_lbr = TRUE;
 reg_win = NULL;
+reg_toolong = FALSE;
 ireg_ic = rmp-rm_ic;
 #ifdef FEAT_MBYTE
 ireg_icombine = FALSE;
@@ -3399,6 +3401,7 @@ vim_regexec_multi(rmp, win, buf, lnum, c
 reg_firstlnum = lnum;
 reg_maxline = reg_buf-b_ml.ml_line_count - lnum;
 reg_line_lbr = FALSE;
+reg_toolong = FALSE;
 ireg_ic = rmp-rmm_ic;
 #ifdef FEAT_MBYTE
 ireg_icombine = FALSE;

On 11 Sep, 17:09, Carlo carlo.teub...@gmail.com wrote:
 On Sep 5, 3:33 am, Peter Odding pe...@peterodding.com wrote:

  The regex is a 77 KB monstrosity that's supposed to match a predefined
  set of strings in 2html.vim output and is complicated by the fact that
  it also matches strings with embedded HTML tags. The regex is corrupt
  because of a bug in my plug-in; I forgot to escape special characters
  like [.

 I can reproduce this crash with a much simpler, valid, regex:

 $ vim -Ngfu NONE --noplugin -c execute '/' . repeat('a\|', 9000) .
 'a'
 Vim: Caught deadly signal SEGV

 On my machine, it crashes with 9000 but not with 8000 repetitions.

  I'm also attaching a backtrace from GDB and the output of Valgrind,
  which tell me that Vim crashes because of a NULL pointer dereference at
  regexp.c:4730 in the latest Vim 7.3 source. I've tried reasoning about
  this but regmatch() is far too complex for my comprehension at the
  moment :-)

 My backtrace is exactly the same:

 (gdb) bt
 #0  0x0055a545 in regmatch (scan=0x953cba \003) at regexp.c:
 4730
 #1  0x00557dd5 in regtry (prog=0x953ca0, col=0) at regexp.c:
 3711
 #2  0x00557b9c in vim_regexec_both (line=0xabe7c0 , col=0,
 tm=0x0) at regexp.c:3600
 #3  0x005574c7 in vim_regexec (rmp=0x7fffdd00,
 line=0xabe7c0 , col=0) at regexp.c:3347
 #4  0x004b85cd in match_file_pat (pattern=0x0, prog=0x953ca0,
 fname=0xabe7c0 , sfname=0x0, tail=
     0xabe7c0 , allow_dirs=0) at fileio.c:10003
 #5  0x004b7bd2 in auto_next_pat (apc=0x7fffde50,
 stop_at_last=0) at fileio.c:9525
 #6  0x004b77d8 in apply_autocmds_group (event=EVENT_VIMENTER,
 fname=0xabe7c0 , fname_io=0x0, force=0,
     group=-3, buf=0x88c150, eap=0x0) at fileio.c:9358
 #7  0x004b7108 in apply_autocmds (event=EVENT_VIMENTER,
 fname=0x0, fname_io=0x0, force=0, buf=0x88c150)
     at fileio.c:8994
 #8  0x004d3973 in main (argc=6, argv=0x7fffe1e8) at main.c:
 903

 Carlo

 (I attempted to post this message earlier but it somehow didn't make
 it through)



    - Peter Odding

  [crash.vim5K ]function! s:VimCrashOnRegexEval(tags)
    let patterns = []
    let short = s:IgnoreHTML('s') . s:IgnoreHTML(':')
    let long = s:IgnoreHTML('lt;') . s:IgnoreHTML('[Ss][Ii][Dd]') . 
  s:IgnoreHTML('gt;')
    let prefix = '\%(' . short . '\|' . long . '\)'
    for name in a:tags
      let tokens = [prefix]
      for token in split(name, '\...@=\|\W\@=')
         The bug in my original code was that I didn't escape special 
  pattern characters in
         {token} before adding it to {tokens}, but that doesn't mean Vim 
  should crash :-(
        call add(tokens, s:IgnoreHTML(token))
      endfor
      call add(patterns, join(tokens, ''))
    endfor
    execute '/' . escape(join(patterns, '\|'), '~/')
  endfunction

  function! s:IgnoreHTML(s)
    return printf('\%%([^/][^]*%s/[^]\+\|%s\)', a:s, a:s)
  endfunction

  call s:VimCrashOnRegexEval(['s:msg', 'g:loaded_publish', 'foreach_window', 
  's:ei_save',
   \ 's:loaded_scripts', 'tex_fold_enabled', 'g:timer_verbosity', 'Tab', 
  'reload_colors',
   \ 'b:luainspect_syntax_error', 'g:easytags_resolve_links', 's:hif_save', 
  'unresolve_scriptname',
   \ 'g:easytags_always_enabled', 

Re: 2html.vim causes Vim to crash with a SIGSEGV?!

2010-09-11 Fir de Conversatie Peter Odding

Hi Carlo,

I can confirm that the much simpler regex you posted also crashes Vim 
(in the same way) and that your patch fixes the segmentation fault. 
Thanks for taking the time to look into this and posting your patch!


Cheers,

 - Peter Odding

--
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


Re: 2html.vim causes Vim to crash with a SIGSEGV?!

2010-09-11 Fir de Conversatie Carlo Teubner
Peter Odding peter at peterodding.com writes:

 
 The regex is a 77 KB monstrosity that's supposed to match a predefined 
 set of strings in 2html.vim output and is complicated by the fact that 
 it also matches strings with embedded HTML tags. The regex is corrupt 
 because of a bug in my plug-in; I forgot to escape special characters 
 like [.

I can reproduce the same crash with a much simpler, valid, very long regex:
a\|a\|a\|...

$ vim -Ngfu NONE --noplugin -c execute '/' . repeat('a\|', 9000) . 'a'
Vim: Caught deadly signal SEGV

On my system, it crashes with 9000 repetitions but not 8000.

 I'm also attaching a backtrace from GDB and the output of Valgrind, 
 which tell me that Vim crashes because of a NULL pointer dereference at 
 regexp.c:4730 in the latest Vim 7.3 source. I've tried reasoning about 
 this but regmatch() is far too complex for my comprehension at the 
 moment 

gdb shows the same backtrace as yours:

(gdb) bt
#0  0x0055a545 in regmatch (scan=0x953cba \003) at regexp.c:4730
#1  0x00557dd5 in regtry (prog=0x953ca0, col=0) at regexp.c:3711
#2  0x00557b9c in vim_regexec_both (line=0xab3f30 , col=0, tm=0x0) at
regexp.c:3600
#3  0x005574c7 in vim_regexec (rmp=0x7fffdd00, line=0xab3f30 ,
col=0) at regexp.c:3347
#4  0x004b85cd in match_file_pat (pattern=0x0, prog=0x953ca0,
fname=0xab3f30 , sfname=0x0, tail=
0xab3f30 , allow_dirs=0) at fileio.c:10003
#5  0x004b7bd2 in auto_next_pat (apc=0x7fffde50, stop_at_last=0) at
fileio.c:9525
#6  0x004b77d8 in apply_autocmds_group (event=EVENT_VIMENTER,
fname=0xab3f30 , fname_io=0x0, force=0, 
group=-3, buf=0x88c150, eap=0x0) at fileio.c:9358
#7  0x004b7108 in apply_autocmds (event=EVENT_VIMENTER, fname=0x0,
fname_io=0x0, force=0, buf=0x88c150)
at fileio.c:8994
#8  0x004d3973 in main (argc=6, argv=0x7fffe1e8) at main.c:903


Carlo



-- 
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