[Lldb-commits] [PATCH] D75241: [lldb] Adjust TestExec code to be closer to real world code

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 27 04:39:05 PST 2020


teemperor created this revision.
teemperor added reviewers: labath, JDevlieghere.
Herald added subscribers: lldb-commits, abidh.
Herald added a project: LLDB.

For some reason the TestExec test on the macOS bots randomly fails with this error:

  output: * thread #2, stop reason = EXC_BAD_ACCESS (code=1, address=0x108e66000)
    * frame #0: 0x0000000108e66000
  [...]
    File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 25, in test_hitting_exec
      self.do_test(False)
    File "/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/exec/TestExec.py", line 113, in do_test
      "Stopped at breakpoint in exec'ed process.")
  AssertionError: False is not True : Stopped at breakpoint in exec'ed process.
  Config=x86_64-/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang-11

I don't know why the test program is failing and I couldn't reproduce this problem on my own.
This patch is a stab in the dark that just tries to make the test code more similar to code which
we would expect in a user program to make whatever part of macOS happy that is currently
not liking our code.

The actual changes are:

- We pass in argv[0] that is describing otherprog path instead of the current argv[0].
- We pass in a non-null envp (which anyway doesn't seem to be allowed on macOS man page).


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D75241

Files:
  lldb/test/API/functionalities/exec/main.cpp


Index: lldb/test/API/functionalities/exec/main.cpp
===================================================================
--- lldb/test/API/functionalities/exec/main.cpp
+++ lldb/test/API/functionalities/exec/main.cpp
@@ -7,12 +7,15 @@
 #include <string>
 #include <unistd.h>
 
+extern char **environ;
+
 int main(int argc, char const **argv) {
   char *buf = strdup(argv[0]); // Set breakpoint 1 here
   std::string directory_name(::dirname(buf));
 
   std::string other_program = directory_name + "/secondprog";
-  execve(other_program.c_str(), const_cast<char *const *>(argv), nullptr);
+  argv[0] = other_program.c_str();
+  execve(argv[0], const_cast<char *const *>(argv), environ);
   perror("execve");
   abort();
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75241.246911.patch
Type: text/x-patch
Size: 721 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200227/d24d2f34/attachment-0001.bin>


More information about the lldb-commits mailing list