[PATCH] D117793: Fix for spurious UBSan reports when no file descriptors are available.

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 21 10:43:07 PST 2022


eugenis added inline comments.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp:278
   if (pipe(sock_pair))
-    return false;
+    return errno == EMFILE || errno == ENFILE;
   uptr bytes_written =
----------------
rengolin wrote:
> This just means the pipe failed for a "known" problem, not that the memory range is accessible, which is what the return value means.
> 
> If there are no file descriptors left, then this function needs to calculate the accessibility of the memory range in some other way...
Why check errno at all? I don't think *any* error from the pipe() call should be treated as the given memory being inaccessible.

It would be good to print something. Silently failing to detect a bug can be confusing to the user, too. We often do CHECK() in such cases, which is fatal, but it should be fine to keep going in this case - the worst that can happen is we try to access the memory and crash anyway.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117793



More information about the llvm-commits mailing list