|
From: <sv...@va...> - 2005-10-04 23:07:38
|
Author: sewardj
Date: 2005-10-05 00:07:33 +0100 (Wed, 05 Oct 2005)
New Revision: 4861
Log:
If the launcher can't figure out what it's own name is, don't bail
out. Instead, print a warning message, continue, and cause any
attempt to trace into a child process to fail with ECHILD.
Modified:
trunk/coregrind/launcher.c
trunk/coregrind/m_syswrap/syswrap-generic.c
trunk/include/vki-linux.h
Modified: trunk/coregrind/launcher.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/launcher.c 2005-10-04 22:27:22 UTC (rev 4860)
+++ trunk/coregrind/launcher.c 2005-10-04 23:07:33 UTC (rev 4861)
@@ -99,8 +99,16 @@
invokations of valgrind on child processes. */
memset(launcher_name, 0, PATH_MAX+1);
r =3D readlink("/proc/self/exe", launcher_name, PATH_MAX);
- if (r =3D=3D -1)
- barf("readlink(\"/proc/self/exe\") failed.");
+ if (r =3D=3D -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=3D=
yes "
+ "will not work.\n");
+ }
=20
/* tediously augment the env: VALGRIND_LAUNCHER=3Dlauncher_name */
new_line =3D malloc(strlen(VALGRIND_LAUNCHER) + 1=20
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2005-10-04 22:27:22 UTC (=
rev 4860)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2005-10-04 23:07:33 UTC (=
rev 4861)
@@ -2329,6 +2329,16 @@
return;
}
=20
+ /* 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)=20
+ && (VG_(name_of_launcher) =3D=3D NULL
+ || VG_(name_of_launcher)[0] !=3D '/')) {
+ 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);
=20
Modified: trunk/include/vki-linux.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/include/vki-linux.h 2005-10-04 22:27:22 UTC (rev 4860)
+++ trunk/include/vki-linux.h 2005-10-04 23:07:33 UTC (rev 4861)
@@ -1087,6 +1087,7 @@
#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 */
|
|
From: Oswald B. <os...@kd...> - 2005-10-05 07:50:02
|
On Wed, Oct 05, 2005 at 12:07:34AM +0100, sv...@va... wrote:
> If the launcher can't figure out what it's own name is, don't bail
> out. Instead, print a warning message, continue, and cause any
> attempt to trace into a child process to fail with ECHILD.
>
that's no valid error code for execve() - not that any app i know would
care. apart from that the situation doesn't really match the intended
interpretation of this error code. ENOENT is very generic and certainly
confusing when shown to the user ("huh? <program> *is* there ..."),
but the explanation in the linux execve() man page fits pretty well.
</pedant>
--
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
|