The ASanified executable could be launched from different locations. When we cannot find the suppression file relative to the current directory, try to see if the specified path is relative to the location of the executable.
Details
Diff Detail
Event Timeline
Thanks for working on this!
kcc@: We don't have file with default suppressions, do we?
lib/sanitizer_common/sanitizer_mac.cc | ||
---|---|---|
216 | This can cause memory corruption if the length of the result is larger than buf_len. If you intend to call realpath(), you should probably store the result in the pre-allocated buffer of size at least kMaxPathLength, and then internal_strncpy it into buf. | |
lib/sanitizer_common/sanitizer_suppressions.cc | ||
83 | Please make the output parameter last. | |
87 | +1. Looks like we need a named constant for path separator that would be different on POSIX/Windows. It can also be used in functions like StripPathPrefix or StripModuleName. | |
129 | You might add a VPrintf() that would tell the actual path of the file with suppressions used by the runtime. |
kcc@: We don't have file with default suppressions, do we?
We do not, but I would rather prefer to have default suppressions than to work like suggested here.
I assume that the default suppressions are the bugs in libraries we already know about, correct?
My understanding is that those are currently baked into the ASan library.
This workflow is needed for cases where a user runs into an issue in a third party library, which they want to suppress. Allowing them to add the suppressions file can unblock them immediately.
me being stupid... For some reason I thought you are trying to read suppressions from a path relative to the compiler tool chain.
Ignore my previous comments. :)
- Made this friendly to Windows. (Introduced "IsPathSeparator()" instead of a constant since multiple characters can serve as separators on Windows.)
- Addressed all other comments.
- Included a testcase, which I forgot to add the first time around.
lib/sanitizer_common/sanitizer_mac.cc | ||
---|---|---|
217 | You can merge these conditions with && | |
lib/sanitizer_common/sanitizer_suppressions.cc | ||
83 | Function name looks confusing: it return an absolute path, not path relative to executable. | |
86 | if (!ReadBinaryName(exec.data(), exec.size())) return false; ... return true; | |
89 | You can have a buffer overflow on rel_file_path here. Consider taking a length of rel_file_path buffer as an input argument and/or using internal_strncat. | |
108 | const | |
lib/sanitizer_common/sanitizer_win.cc | ||
320 | return c == '\\'; |
LGTM after addressing a few comments below. Thanks!
lib/sanitizer_common/sanitizer_posix.cc | ||
---|---|---|
301 | return path != nullptr && IsPathSeparator(path[0]) | |
lib/sanitizer_common/sanitizer_suppressions.cc | ||
90 | Max(path_to_exec_len, new_file_path_size - 1); | |
107 | Move these declarations closer to the place where they are actually used. | |
127 | should this be file_path? |
Looks good in general
lib/sanitizer_common/sanitizer_common.h | ||
---|---|---|
221 | Nit: how about "GetBinaryName"? After all, you're not reading it on Mac. |
Comments addressed and committed in r230723.
lib/sanitizer_common/sanitizer_common.h | ||
---|---|---|
221 | The function only gets the file on Mac, but not on other platforms, so I don't think it should be renamed. (I've moved this from sanitizer_linux.h) |
Nit: how about "GetBinaryName"? After all, you're not reading it on Mac.