|
From: Alex B. <ker...@be...> - 2006-09-07 17:17:23
|
On Thu, 2006-09-07 at 15:09 +0100, Tom Hughes wrote: > In message <115...@ok...> > Alex Bennee <ker...@be...> wrote: > > <snip> > > Additionally running the program native with the instrumentation never > > clobbers the pid variable to 0. I think this points more towards a a bug > > with Valgrind. > <snip> > Far more likely is that running under valgrind has changed the > layout of memory in your program so that an existing problem in > your program is manifesting itself by overwriting something more > important. Doh! I should of looked more closely at the syscalls setPid 15817 (@0x424f5f8) .. .. getLock tc=0x424e208, pid=15817 SYSCALL[15817,1]( 1) ... [async] --> Success(0x20) SYSCALL[15817,1]( 9) sys_mmap ( 0x6C000, 198787072, 7, 50, -1, 0 )==15817== Warning: set address range perms: large range 198787072 (defined) --> [pre-success] Success(0x6C000) SYSCALL[15817,1]( 9) sys_mmap ( 0x2A96000000, 4096, 1, 34, -1, 0 ) --> [pre-success] Success(0xBE00000) SYSCALL[15817,1]( 11) sys_munmap ( 0xBE00000, 4096 )[sync] --> Success(0x0) SYSCALL[15817,1]( 1) sys_write ( 2, 0x7FEFFC070, 28 ) --> [async] ... getLock tc=0x424e208, pid=0 We let our subject application mmap right over our heap area. I tried messing around with valgrind's configure to leave enough space for us, however: cat /proc/15817/maps <snip> 6ff00000-70377000 r-xp 00000000 00:18 1552482 dynamite 70477000-7048a000 rw-p 00477000 00:18 1552482 dynamite 7048a000-704d3000 rw-p 7048a000 00:00 0 704d3000-704d4000 rwxp 704d3000 00:00 0 78000000-78169000 r-xp 00000000 08:03 35037 /usr/local/lib/valgrind/amd64-linux/memcheck 78269000-7826a000 rw-p 00169000 08:03 35037 /usr/local/lib/valgrind/amd64-linux/memcheck <snip> It looks as though our binary is where it wants to be the heap itself has moved down into memory. There are two options I think of: 1. Stop Valgrind relocating the heap 2. Tweak our program to discover the heap and then disallow maps in the region. We currently assume that the heap follows straight after bss but I don't think it does when we are being Valgrinded. Is there anyway to force Valgrind to use a particular location for heap? -- Alex, homepage: http://www.bennee.com/~alex/ Trying to be happy is like trying to build a machine for which the only specification is that it should run noiselessly. |