How to set ASAN/UBSAN reporting output
<p>I would like to run my unit test suite with <code>-fsanitize=address,undefined</code> and have all sanitizer errors be written to a <code>report.txt</code> file. By default all sanitizer errors get written to stdout, however the software also writes info to stdout so this makes it difficult to detect errors. I tried:</p>

<pre><code>export ASAN_OPTIONS="log_path=asan.log"
./mytests
</code></pre>

<p>And I also tried calling the C API before running tests:</p>

<pre><code>#include &lt;sanitizer/asan_interface.h&gt;

__sanitizer_set_report_path("/tmp/asan.log")
</code></pre>

<p>However neither seems to work, all errors just get written to stdout. I am using Debian testing:</p>

<pre><code>root@94e239ad460a:~# gcc --version
gcc (Debian 6.1.1-11) 6.1.1 20160802
Copyright (C) 2016 Free Software Foundation, Inc.
</code></pre>

<p>Is there any alternative method that I can save the sanitizer error from my unit tests somewhere?</p>