[PATCH] [compiler-rt] Allow suppression file paths be relative to the location of the executable.

Alexey Samsonov vonosmas at gmail.com
Wed Feb 4 17:47:38 PST 2015

Thanks for working on this!

kcc@: We don't have file with default suppressions, do we?

Comment at: lib/sanitizer_common/sanitizer_mac.cc:216
@@ +215,3 @@
+  if (_NSGetExecutablePath(exe_path.data(), &size) == 0)
+    if (realpath(exe_path.data(), buf) != 0)
+      return internal_strlen(buf);
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`.
Alternatively, assert that `buf_len` is large enough.

Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:83
@@ -82,1 +82,3 @@
+static bool GetPathRelativeToExec(/*out*/char *rel_file_path,
+                                  const char *file_path){
Please make the output parameter last.

Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:87
@@ +86,3 @@
+  if (ReadBinaryName(exec.data(), exec.size())) {
+    if (const char *slash_pos = internal_strrchr(exec.data(), '/')) {
+      uptr path_to_exec_len = slash_pos - exec.data() + 1;
kcc wrote:
> this is probably unfriendly to windows. 
+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`.

Comment at: lib/sanitizer_common/sanitizer_suppressions.cc:126
@@ -97,3 +125,3 @@
You might add a VPrintf() that would tell the actual path of the file with suppressions used by the runtime.



More information about the llvm-commits mailing list