|
From: <sv...@va...> - 2009-06-29 06:57:34
|
Author: njn
Date: 2009-06-29 07:57:30 +0100 (Mon, 29 Jun 2009)
New Revision: 10384
Log:
Make the Linux launcher more like the Darwin one in how it reads the
executable headers. This means it no longer crashes on an empty executable.
Fixes bug 156065.
Added:
trunk/none/tests/empty-exe.stderr.exp
trunk/none/tests/empty-exe.vgtest
Modified:
trunk/coregrind/launcher-linux.c
Modified: trunk/coregrind/launcher-linux.c
===================================================================
--- trunk/coregrind/launcher-linux.c 2009-06-29 05:19:15 UTC (rev 10383)
+++ trunk/coregrind/launcher-linux.c 2009-06-29 06:57:30 UTC (rev 10384)
@@ -112,7 +112,8 @@
static const char *select_platform(const char *clientname)
{
int fd;
- unsigned char *header;
+ uint8_t header[4096];
+ ssize_t bytes;
const char *platform = NULL;
long pagesize = sysconf(_SC_PAGESIZE);
@@ -123,12 +124,12 @@
return NULL;
// barf("open(%s): %s", clientname, strerror(errno));
- if ((header = mmap(NULL, pagesize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED)
+ bytes = read(fd, header, sizeof(header));
+ close(fd);
+ if (bytes != sizeof(header)) {
return NULL;
- // barf("mmap(%s): %s", clientname, strerror(errno));
+ }
- close(fd);
-
if (header[0] == '#' && header[1] == '!') {
char *interp = (char *)header + 2;
char *interpend;
Added: trunk/none/tests/empty-exe.stderr.exp
===================================================================
--- trunk/none/tests/empty-exe.stderr.exp (rev 0)
+++ trunk/none/tests/empty-exe.stderr.exp 2009-06-29 06:57:30 UTC (rev 10384)
@@ -0,0 +1,2 @@
+
+
Added: trunk/none/tests/empty-exe.vgtest
===================================================================
--- trunk/none/tests/empty-exe.vgtest (rev 0)
+++ trunk/none/tests/empty-exe.vgtest 2009-06-29 06:57:30 UTC (rev 10384)
@@ -0,0 +1,9 @@
+# Bug 162020: running an empty executable used to crash Valgrind. Note that
+# the (old) crash message gets filtered out, so it's the presence of the
+# blank two lines in the .stderr.exp file that are important -- they
+# indicate it ran to completion. If the crash occurs, the .stderr.out file
+# is empty.
+prereq: touch empty-exe && chmod u+x empty-exe
+prog: empty-exe
+vgopts:
+cleanup: rm -f empty-exe
|