[PATCH] D109794: [Sanitizer] Allow setting the report path to create directory

Denis Nikitin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 11 16:05:40 PST 2022


denik added a comment.

In D109794#3314322 <https://reviews.llvm.org/D109794#3314322>, @tejohnson wrote:

> In D109794#3313433 <https://reviews.llvm.org/D109794#3313433>, @denik wrote:
>
>>> Are you able to patch in D119495 <https://reviews.llvm.org/D119495> and see if that fixes the issue?
>>
>> Yes. D119495 <https://reviews.llvm.org/D119495> fixed the problem. Thanks for the quick solution!
>
> Great, will try to get this submitted today, once I address the comments.
>
>> Just curious, did `__llvm_profile_recursive_mkdir` also create directories in a similar way (ignoring EEXIST status)? I'm asking because the same test was creating a PGO profile in a sandbox and it did not fail.
>
> Interesting - I actually modeled the implementation here exactly on that function. It has the same unconditional mkdir with the same comment about ignoring failures due to existing directories.
>
>> While debugging the sandbox (before your fix), I noticed that the test crashed when the sandbox was checking `lstat` of the path from `__sanitizer::CreateDir()`.  Can it be that the sanitizer intercepted the call but since it was `__asan::AsanInitInternal()` the handler was not set up yet? This would explain why it worked for PGO.
>
> Not totally following - which handler?

I meant the sanitizer interceptor: https://github.com/llvm-mirror/compiler-rt/blob/master/lib/sanitizer_common/sanitizer_common_interceptors.inc#L6510
With llvm debug info enabled:

  (gdb) bt
  #0  __interceptor_lstat ()
      at /var/tmp/portage/sys-devel/llvm-14.0_pre437112_p20211208-r7/work/llvm-14.0_pre437112_p20211208/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:6878
  #1  0x00007ffff7f9e297 in sb_mkdirat_pre_check (func=0x7ffff7f963e0 "mkdir", pathname=0x31bfdc <__sanitizer::report_file+12> "/build",
      dirfd=-100) at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/pre_check_mkdirat.c:40
  #2  0x00007ffff7fa167b in mkdir_DEFAULT (pathname=0x31bfdc <__sanitizer::report_file+12> "/build", mode=493)
      at /var/tmp/portage/sys-apps/sandbox-2.29/work/sandbox-2.29/libsandbox/wrapper-funcs/__wrapper_simple.c:51
  #3  0x00000000002faaab in __sanitizer::CreateDir(char const*) ()
      at /var/tmp/portage/sys-devel/llvm-14.0_pre437112_p20211208-r7/work/llvm-14.0_pre437112_p20211208/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp:154
  #4  0x00000000002eaab6 in RecursiveCreateParentDirs ()
      at /var/tmp/portage/sys-devel/llvm-14.0_pre437112_p20211208-r7/work/llvm-14.0_pre437112_p20211208/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp:87
  #5  SetReportPath ()
      at /var/tmp/portage/sys-devel/llvm-14.0_pre437112_p20211208-r7/work/llvm-14.0_pre437112_p20211208/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp:112
  #6  0x00000000002e03b5 in AsanInitInternal ()
      at /var/tmp/portage/sys-devel/llvm-14.0_pre437112_p20211208-r7/work/llvm-14.0_pre437112_p20211208/compiler-rt/lib/asan/asan_rtl.cpp:426
  (gdb) frame 0
  #0  __interceptor_lstat ()
      at /var/tmp/portage/sys-devel/llvm-14.0_pre437112_p20211208-r7/work/llvm-14.0_pre437112_p20211208/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:6878
  6878      COMMON_INTERCEPTOR_ENTER(ctx, lstat, path, buf);
  (gdb) s
  
  Program received signal SIGSEGV, Segmentation fault.
  0x0000000000000000 in ?? ()

It crashes on the COMMON_INTERCEPTOR_ENTER() call.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109794/new/

https://reviews.llvm.org/D109794



More information about the llvm-commits mailing list