|
From: Marcin Ś. <mar...@gm...> - 2014-09-26 20:52:01
|
Hey,
Below is a simple program which crashes under Valgrind, but runs correctly otherwise.
It's weird artificial test case (I didn't hit it with real app), but I think it's
technically valid.
strace shows:
mmap(0x100000001, 100, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x100000000
--
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
int main(void)
{
int fd = open("/dev/zero", O_RDWR);
unsigned int *v = mmap((void *)0x100000001, 100, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
*v = 0;
return 0;
}
--
==21563== Memcheck, a memory error detector
==21563== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==21563== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==21563== Command: ./a.out
==21563==
==21563== Invalid write of size 4
==21563== at 0x4005CE: main (in a.out)
==21563== Address 0xffffffffffffffff is not stack'd, malloc'd or (recently) free'd
==21563==
==21563==
==21563== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==21563== Access not within mapped region at address 0xFFFFFFFFFFFFFFFF
==21563== at 0x4005CE: main (in a.out)
==21563== If you believe this happened as a result of a stack
==21563== overflow in your program's main thread (unlikely but
==21563== possible), you can try to increase the size of the
==21563== main thread stack using the --main-stacksize= flag.
==21563== The main thread stack size used in this run was 8388608.
==21563==
==21563== HEAP SUMMARY:
==21563== in use at exit: 0 bytes in 0 blocks
==21563== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==21563==
==21563== All heap blocks were freed -- no leaks are possible
==21563==
==21563== For counts of detected and suppressed errors, rerun with: -v
==21563== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
|