I'm on Windows using Visual Studio compiler.
I'm using /fsanitize=address to compile with AddressSanitizer.
I run my exe from command line.
I want my exe to
- continue on ASAN errors and
- write all ASAN errors to a logfile
The documentation of ASAN_OPTIONS suggests the following syntax:
set ASAN_OPTIONS=continue_on_error=1:log_path=log_file my.exe
However, I only can (partially) succeed, when I
a) omit the exe name AND
b) use only 1 option
When specifying the executable name, I always get the error
Internal error duing continue on error: Fail on write()
(no matter
whether I use the full path name or the exe file name only,
or if I'm in the exe's directory or not)
And when using more than 1 option, only 1 option is working.
I tried the delimiter characters (space) and :.
Surrounding the whole option string with quotes (") is counterproductive: then no option is recognized at all.
Edit after @yugr's answer: I experimented a little further and experienced the following:
- 2 options:
>set ASAN_OPTIONS=log_path='D:\_tmp\log_file':continue_on_error=1
continues, but does not writa a logfile - exchanged option order:
>set ASAN_OPTIONS=continue_on_error=1:log_path='D:\_tmp\log_file'
continues, but does not writa a logfile - logfile only:
set ASAN_OPTIONS=log_path='D:\_tmp\log_file'
works: does writa a logfile - different delimiter: space
>set ASAN_OPTIONS=continue_on_error=1 log_path='D:\_tmp\log_file'
continues, but does not writa a logfile - exchanged option order with delimiter space:
>set ASAN_OPTIONS=log_path='D:\_tmp\log_file' continue_on_error=1
continues, but does not writa a logfile - different delimiter: semicolon
>set ASAN_OPTIONS=continue_on_error=1;log_path='D:\_tmp\log_file'
>my.exe
Internal error duing continue on error: Fail on write()
Edit end.
I tried the option log_path with
stderr
=> AddressSanitizer output occurs on stderr instead of stdout (note: the doc states a default value of stderr, which is obviously not the case here)log_file
=> works (the file log_file.<pid> occurs in the current directory, not in the exe directory)D:\_tmp\log_file
=> givesAddressSanitizer: ERROR: expected '=' in ASAN_OPTIONS- don't know why:
> echo %ASAN_OPTIONS%
log_path=D:\_tmp\log_file
Any hint is highly appreciated on the 3 dubieties (exe name in options, >1 option, path in log_path option).
That syntax is Linux-specific. On Windows you should run it with two separate commands
Multiple flags in
ASAN_OPTIONScan be separated via:or(whitespace):Yes, this is a (mis)feature of Asan - it treats any unescaped colon as option separator so when you do
it treats "\_tmp\log_file" as second option and fails to parse it. You should escape filename to prevent Asan from doing this:
This happens because
continue_on_error=1forces output to stdout and overrides thelog_pathsetting.