]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
If the launcher can't figure out what it's own name is, don't bail
authorJulian Seward <jseward@acm.org>
Tue, 4 Oct 2005 23:07:33 +0000 (23:07 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 4 Oct 2005 23:07:33 +0000 (23:07 +0000)
out.  Instead, print a warning message, continue, and cause any
attempt to trace into a child process to fail with ECHILD.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4861

coregrind/launcher.c
coregrind/m_syswrap/syswrap-generic.c
include/vki-linux.h

index 8c3c395379c74975dcb89d1a8021f50df3252297..81404910b9b7eeed6ffdbfb57e35b9bbbb2ab7bd 100644 (file)
@@ -99,8 +99,16 @@ int main(int argc, char** argv, char** envp)
       invokations of valgrind on child processes. */
    memset(launcher_name, 0, PATH_MAX+1);
    r = readlink("/proc/self/exe", launcher_name, PATH_MAX);
-   if (r == -1)
-      barf("readlink(\"/proc/self/exe\") failed.");
+   if (r == -1) {
+      /* If /proc/self/exe can't be followed, don't give up.  Instead
+         continue with an empty string for VALGRIND_LAUNCHER.  In the
+         sys_execve wrapper, this is tested, and if found to be empty,
+         fail the execve. */
+      fprintf(stderr, "valgrind: warning (non-fatal): "
+                      "readlink(\"/proc/self/exe\") failed.\n");
+      fprintf(stderr, "valgrind: continuing, however --trace-children=yes "
+                      "will not work.\n");
+   }
 
    /* tediously augment the env: VALGRIND_LAUNCHER=launcher_name */
    new_line = malloc(strlen(VALGRIND_LAUNCHER) + 1 
index 3bde6622c4d8fe2c3b26a04376d7825204fb86c8..f4a9cb7e74bd12983e28daa3b199dc02c4140a91 100644 (file)
@@ -2329,6 +2329,16 @@ PRE(sys_execve)
       return;
    }
 
+   /* If we're tracing the child, and the launcher name looks bogus
+      (possibly because launcher.c couldn't figure it out, see
+      comments therein) then we have no option but to fail. */
+   if (VG_(clo_trace_children) 
+       && (VG_(name_of_launcher) == NULL
+           || VG_(name_of_launcher)[0] != '/')) {
+      SET_STATUS_Failure( VKI_ECHILD ); /* "No child processes" */
+      return;
+   }
+
    /* After this point, we can't recover if the execve fails. */
    VG_(debugLog)(1, "syswrap", "Exec of %s\n", (Char*)ARG1);
 
index 3fe2354e20af4c86c5dbd23aa6a93fe019730d1c..599ac1a5c004dd530fee95afde96891b9dc452ae 100644 (file)
@@ -1087,6 +1087,7 @@ struct  vki_seminfo {
 #define        VKI_EINTR                4      /* Interrupted system call */
 #define VKI_ENOEXEC              8      /* Exec format error */
 #define        VKI_EBADF                9      /* Bad file number */
+#define VKI_ECHILD              10      /* No child processes */
 #define VKI_EAGAIN             11      /* Try again */
 #define VKI_EWOULDBLOCK                VKI_EAGAIN
 #define        VKI_ENOMEM              12      /* Out of memory */