[PATCH] PR20721: Don't let UBSan print inaccessible memory
Alexey Samsonov
vonosmas at gmail.com
Tue Sep 9 15:29:01 PDT 2014
================
Comment at: lib/sanitizer_common/sanitizer_posix_libcdep.cc:171
@@ +170,3 @@
+ int sock_pair[2];
+ if (pipe(sock_pair))
+ return false;
----------------
eugenis wrote:
> Pipes have capacity, and large writes can block.
> Maybe write to /dev/null instead?
>
See http://stackoverflow.com/questions/4611776/isbadreadptr-analogue-on-unix#comment23029943_4611930 - writing to /dev/null may always succeed.
================
Comment at: lib/sanitizer_common/sanitizer_posix_libcdep.cc:171
@@ +170,3 @@
+ int sock_pair[2];
+ if (pipe(sock_pair))
+ return false;
----------------
samsonov wrote:
> eugenis wrote:
> > Pipes have capacity, and large writes can block.
> > Maybe write to /dev/null instead?
> >
> See http://stackoverflow.com/questions/4611776/isbadreadptr-analogue-on-unix#comment23029943_4611930 - writing to /dev/null may always succeed.
If handling EINTR is not enough, I'd rather assert that "size" argument is reasonable small.
================
Comment at: lib/sanitizer_common/sanitizer_posix_libcdep.cc:173
@@ +172,3 @@
+ return false;
+ uptr bytes_written =
+ internal_write(sock_pair[1], reinterpret_cast<void *>(beg), size);
----------------
glider wrote:
> internal_write() returns sptr, not uptr (at least it must).
> Also, when bytes_written == size (assuming size != -1), internal_iserror() is always false.
I believe we have a custom calling convention for returning errno from syscalls on Linux...
http://reviews.llvm.org/D5253
More information about the llvm-commits
mailing list