[PATCH] D44579: [asan] Clean up some confusing code in `test/asan/TestCases/Darwin/segv_read_write.c`

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 16 13:05:56 PDT 2018


delcypher created this revision.
delcypher added reviewers: kubamracek, aizatsky.
Herald added a subscriber: Sanitizers.
delcypher edited the summary of this revision.

[asan] Clean up some confusing code in
`test/asan/TestCases/Darwin/segv_read_write.c`

- The `fd` arg passed to `mmap()` should be `-1`. It is not definedwhat passing `0` does on Darwin.

- The comment about the shadow memory doesn't make any sense to me, so I'm removing it.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D44579

Files:
  test/asan/TestCases/Darwin/segv_read_write.c


Index: test/asan/TestCases/Darwin/segv_read_write.c
===================================================================
--- test/asan/TestCases/Darwin/segv_read_write.c
+++ test/asan/TestCases/Darwin/segv_read_write.c
@@ -9,11 +9,8 @@
 __attribute__((noinline)) void Read(int *ptr) { sink = *ptr; }
 __attribute__((noinline)) void Write(int *ptr) { *ptr = 0; }
 int main(int argc, char **argv) {
-  // Writes to shadow are detected as reads from shadow gap (because of how the
-  // shadow mapping works). This is kinda hard to fix. Test a random address in
-  // the application part of the address space.
   void *volatile p =
-      mmap(nullptr, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, 0, 0);
+      mmap(nullptr, 4096, PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0);
   munmap(p, 4096);
   if (argc == 1)
     Read((int *)p);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44579.138750.patch
Type: text/x-patch
Size: 827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180316/0f3cfeb4/attachment.bin>


More information about the llvm-commits mailing list