This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Don't treat colon before slash as a flag separator
AcceptedPublic

Authored by rnk on Jun 11 2018, 1:52 PM.

Details

Summary

Users often have path escaping bugs in their ASan options. They do
things like this
ASAN_OPTIONS=foo=1:bar=0:symbolizer_path=%s
... where %s is an absolute path. They may have project rules that
require paths to not contain spaces, so they get away with this on
Linux. Then they come to Windows, and the substituted options look like:
symbolizer_path=C:/path/to/llvm-symbolizer.exe
This doesn't work because we have chosen colon to be an option
separator.

Many users have hit this, it affects the Go race detector, and it
affects Chromium Windows ASan usage. Try to make their life a little
easier by not treating colon before slash as a flag separator.

Fixes https://github.com/google/sanitizers/issues/884

Event Timeline

rnk created this revision.Jun 11 2018, 1:52 PM
vitalybuka added inline comments.Jun 13 2018, 4:39 PM
compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cc
77

All these variables are mapped to the same C++ members. So not sure if it's worth it but what if we generalize to:
":" is separateor IFF it's followed by "[a-zA_Z0-9_]+="

rnk added inline comments.Jun 14 2018, 10:10 AM
compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cc
77

I think that'll be too magic. Consider this case where the user just forgets to say "flag2" before "=":

flag1=val1:=val2:flag3=val3

We'll parse that as flag1="val1:=val2" and not give any errors. The same could be said with this if they add a slash after a colon that's supposed to be a separator, but hopefully it's not an issue in practice.

vitalybuka accepted this revision.Jun 14 2018, 12:04 PM

works for me any way

compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cc
77

Both approaches too magic but one can avoid OS specifics.
To get error there we can just use "[a-zA_Z0-9_]*=" and it will hit same error :-)

BTW. The patch does not cover "c:win\path" which is impractical but valid path.

This revision is now accepted and ready to land.Jun 14 2018, 12:04 PM