Skip to content
K.Takata edited this page Dec 23, 2021 · 5 revisions

Building an ASAN -enabled vim

  1. uncomment the following line in vim/src/Makefile:
SANITIZER_CFLAGS = -g -O0 -fsanitize=address -fno-omit-frame-pointer
  1. clean and rebuild vim
$ cd vim/src/
$ make clean
$ make -j8
  1. reproduce the issue while redirecting stderr of vim into a file
$ ./vim 2> asan log
(perform steps to reproduce the issue)

If a memory error is found (overflow, use of free memory…) the file asan.log should contain useful information.

Creating a GDB stack trace

$ make clean
$ make distclean
$ sed -i 's/#ABORT_CFLAGS = -DABORT_ON_INTERNAL_ERROR/ABORT_CFLAGS = -DABORT_ON_INTERNAL_ERROR/ ; s/#CFLAGS = -g$/CFLAGS = -g -O0/ ; s@#STRIP = /bin/true@STRIP = /bin/true@' src/Makefile
$ make
$ gdb -q --args /path/to/vim/binary -Nu NONE -S /tmp/crash.vim
(gdb) set logging on
# start Vim so that it crashes
(gdb) run
# Print the backtrace.
# If it's too long, it will be printed in a pager.
# If so, press Enter repeatedly to scroll until you reach the bottom of the pager.
(gdb) bt full
(gdb) quit
# the backtrace should be in gdb.txt