Testing Mercurial with ASAN

Yuya Nishihara yuya at tcha.org
Tue Sep 4 14:19:24 UTC 2018


On Fri, 10 Apr 2015 09:53:05 -0700, Bryan O'Sullivan wrote:
> If you haven't come across the Address Sanitizer that's shipped with clang
> and gcc the past few years, start here:
> https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer
> 
> I spent some time building and testing Mercurial against both clang (3.6)
> and gcc (4.9) ASAN implementations yesterday. The good, and
> unsurprising-to-me news: t's completely clean right now.
> 
> Here are some notes, in case anyone wants to reproduce.
> 
> Normally, ASAN is built directly into an executable. The standard ASAN
> libraries are thus static libraries, not shared objects. This doesn't work
> with Mercurial at all, as the C routines in Mercurial are loaded as shared
> objects.

I tried ASAN to see if the nodetree bug could be detected. It's gcc 8.2, and
seems working nicely. What I needed is to teach Python to use the standard
malloc.

  $ cd python
  $ ./configure --prefix=$HOME/opt/python-2.7.13-asan --without-pymalloc \
  CFLAGS='-O1 -fsanitize=address -fno-omit-frame-pointer -g -fwrapv -fstack-protector-strong -Wall' \
  LDFLAGS=-lasan
  $ ASAN_OPTIONS=detect_leaks=0 make
  $ make install

  $ cd mercurial
  $ make clean local PYTHON=$HOME/opt/python-2.7.13-asan/bin/python
  $ cd tests
  $ $HOME/opt/python-2.7.13-asan/bin/python ./run-tests.py -l test-revisions.t

It will report some leaks. I haven't investigated if all of them are false
positives. To disable the leak detection, set ASAN_OPTIONS=detect_leaks=0.


More information about the Mercurial-devel mailing list