Crash with legal VimScript

9 views
Skip to first unread message

Meikel Brandmeyer

unread,
May 1, 2009, 5:25:15 PM5/1/09
to vim...@googlegroups.com
Hi,

I ran into a problem with MacVim. I'm not sure where it comes from.

The problem can be reproduced as follows:
1. Source the attached file.
2. Create a new buffer: :call foo#Buffer.New()
3. Close the new window by pressing q.

Shortly thereafter vim will crash while garbage collecting.

6 libSystem.B.dylib 0x94b9d2bb _sigtramp + 43
7 ??? 0xffffffff 0 + 4294967295
8 Vim 0x0002b65c dict_free + 185
9 Vim 0x0002b6b2 dict_unref + 33
10 Vim 0x0002afa4 clear_tv + 136
11 Vim 0x0002c866 vars_clear_ext + 85
12 Vim 0x0002c8ad vars_clear + 19
13 Vim 0x0002c8d4 free_funccal + 37
14 Vim 0x0002ccf3 garbage_collect + 514

James Vega on #vim on freenode.net tried the on different
vim versions, which all worked ok. I saw the problem with
MacVim snapshot 42 and snapshot 45.

I'm not so involved in the guts of vim, so I'm not sure how to
track this down further, but it seems to be Mac specific.

Any ideas?

Sincerely
Meikel

foo.vim

björn

unread,
May 1, 2009, 6:31:11 PM5/1/09
to vim...@googlegroups.com
2009/5/1 Meikel Brandmeyer:

I can confirm this crash on Snapshot 45, OS X 10.5.6, Intel.

I'm not very familiar with Vim core either so I'm not sure how to go
about debugging this (I'll give it a go when I get a chance though).
Any assistance would be greatly appreciated!

Thanks,
Björn

Nico Weber

unread,
May 2, 2009, 7:18:44 PM5/2/09
to vim...@googlegroups.com
Hi,

This was a bug in core vim. I've submitted a fix: http://groups.google.com/group/vim_dev/browse_thread/thread/24a59dfe042901df
Let's hope it gets accepted.

I used valgrind to find the problem. Once I had valgrind set up, it
took only seconds to find the exact line number where the problem
occurred (it took bit longer to understand the code well enough to
find a fix, though :-P). I feel valgrind is very useful, but there's
not much information on how to use it on OS X, so I thought I'd post a
short howto. Here goes:

# Obtain valgrind. There's no binary yet (needs 140mb to compile).
cd ~/src
svn co svn://svn.valgrind.org/valgrind/branches/DARWIN valgrind
cd valgrind/
mvim README
./autogen.sh
./configure # --prefix=/Users/nico/local/
make -j2
sudo make install # no sudo if --prefix used above
valgrind ls -l # works!

# Build vim with debug info
cd ~/src/MacVim/src
CFLAGS=-g ./configure --enable-gui=macvim --enable-multibyte --enable-
pythoninterp --enable-cscope
make -j2
cd MacVim
xcodebuild -configuration Debug

# For some reason, valgrind needs a dSYM file to output line numbers.
Keeping
# the dSYM file in snyc is less pain then using `atos` manually all
the time, so:
cd build/Debug/MacVim.app/Contents/MacOS
dsymutil Vim # don't forget to do that after every buid
cd -

# Start valgrind with vim (luckily, this bug needs no GUI):
valgrind --leak-check=full build/Debug/MacVim.app/Contents/MacOS/Vim
--noplugins 2> ~/valgrind.txt

# Now manually do `:so foo.vim` :call foo#Buffer.new()` `:q`,
# then open valgrind.txt


With the line number information, I then went ot Markus Heidelberg's
git repo, which has useful commit logs and found http://repo.or.cz/w/vim_extended.git?a=commitdiff;h=4706b1fe9b1053f3d8c3c2f477d6570eb3473966
. After that, it was comparably easy to come up with a fix.

Nico

DanKegel

unread,
May 28, 2009, 12:16:26 PM5/28/09
to vim_mac
On May 2, 4:18 pm, Nico Weber <nicolaswe...@gmx.de> wrote:
> I feel valgrind is very useful, but there's  
> not much information on how to use it on OS X, so I thought I'd post a  
> short howto. Here goes:
>
> # Obtain valgrind. There's no binary yet (needs 140mb to compile).
> cd ~/src
> svn co svn://svn.valgrind.org/valgrind/branches/DARWIN valgrind

The DARWIN branch has been merged to trunk. As of today,
valgrind's trunk supports the mac! See
http://blog.mozilla.com/nnethercote/2009/05/28/mac-os-x-now-supported-on-the-valgrind-trunk/
Reply all
Reply to author
Forward
0 new messages