[PATCH] PR20721: Don't let UBSan print inaccessible memory

Alexey Samsonov vonosmas at gmail.com
Wed Sep 17 11:02:14 PDT 2014


================
Comment at: lib/sanitizer_common/sanitizer_posix_libcdep.cc:169
@@ -168,1 +168,3 @@
 
+bool IsAccessibleMemoryRange(uptr beg, uptr size) {
+  int sock_pair[2];
----------------
glider wrote:
> Any limits on |size|?
> I think it must be an sptr greater than -1 (you're going to compare bytes_written to it) and less than kPageSize (otherwise it'll take too much time to check chunks of too big size)
I pass beg/end instead and check that beg <= end and end - beg < 10*pagesize

================
Comment at: lib/sanitizer_common/sanitizer_posix_libcdep.cc:177
@@ +176,3 @@
+  bool res =
+      !internal_iserror(bytes_written, &write_errno) && bytes_written == size;
+  internal_close(sock_pair[0]);
----------------
ygribov wrote:
> Perhaps assert that write_errno == EFAULT in case of error?
Done

================
Comment at: lib/sanitizer_common/sanitizer_win.cc:526
@@ +525,3 @@
+bool IsAccessibleMemoryRange(uptr beg, uptr size) {
+  UNIMPLEMENTED();
+}
----------------
glider wrote:
> I suggest making this function always return true and adding a FIXME
Done.

http://reviews.llvm.org/D5253






More information about the llvm-commits mailing list