[PATCH] D17228: Fix bug in SanitizerCommon.StartSubprocessTest causing flaky behavior.

Zia Ansari via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 16:12:46 PST 2016


zansari created this revision.
zansari added reviewers: aizatsky, samsonov, earthdok.
zansari added a subscriber: llvm-commits.

The tests

   SanitizerCommon-Unit :: Sanitizer-i386-Test/SanitizerCommon.StartSubprocessTest
   SanitizerCommon-Unit :: Sanitizer-x86_64-Test/SanitizerCommon.StartSubprocessTest

can randomly fail depending on stack layout and random bits on the stack.
This is due to a string of arrays not being properly NULL terminated before being passed to "execv". From the docs:

   "The execv(), execvp(), and execvpe() functions provide an array of pointers to null-terminated strings that represent the argument list available to the new program. The first argument, by convention, should point to the filename associated with the file being executed. The array of pointers must be terminated by a NULL pointer."




http://reviews.llvm.org/D17228

Files:
  llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cc

Index: llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cc
===================================================================
--- llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cc
+++ llvm/projects/compiler-rt/lib/sanitizer_common/tests/sanitizer_linux_test.cc
@@ -271,7 +271,7 @@
 #else
   const char *shell = "/bin/sh";
 #endif
-  const char *argv[] = {shell, "-c", "echo -n 'hello'"};
+  const char *argv[] = {shell, "-c", "echo -n 'hello'", (char *)NULL};
   int pid = StartSubprocess(shell, argv,
                             /* stdin */ kInvalidFd, /* stdout */ pipe_fds[1]);
   ASSERT_GT(pid, 0);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17228.47873.patch
Type: text/x-patch
Size: 657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160213/1eb70997/attachment.bin>


More information about the llvm-commits mailing list