mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 18:13:01 +00:00
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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10384
This commit is contained in:
parent
a95af1babe
commit
07a1251a20
@ -112,7 +112,8 @@ static const char *find_client(const char *clientname)
|
||||
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,11 +124,11 @@ static const char *select_platform(const char *clientname)
|
||||
return NULL;
|
||||
// barf("open(%s): %s", clientname, strerror(errno));
|
||||
|
||||
if ((header = mmap(NULL, pagesize, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED)
|
||||
return NULL;
|
||||
// barf("mmap(%s): %s", clientname, strerror(errno));
|
||||
|
||||
bytes = read(fd, header, sizeof(header));
|
||||
close(fd);
|
||||
if (bytes != sizeof(header)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (header[0] == '#' && header[1] == '!') {
|
||||
char *interp = (char *)header + 2;
|
||||
|
||||
2
none/tests/empty-exe.stderr.exp
Normal file
2
none/tests/empty-exe.stderr.exp
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
9
none/tests/empty-exe.vgtest
Normal file
9
none/tests/empty-exe.vgtest
Normal file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user