Bug 225188 - valgrind reports invalid read/write errors on memory allocated using mmap + mprotect
Summary: valgrind reports invalid read/write errors on memory allocated using mmap + m...
Status: RESOLVED DUPLICATE of bug 205541
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.5.0
Platform: Debian unstable Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-01 20:44 UTC by Zoltan Varga
Modified: 2010-02-01 22:17 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Varga 2010-02-01 20:44:51 UTC
Testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#include <sys/mman.h>
#include <stdio.h>

void main ()
{
	void *ptr = mmap (NULL, getpagesize () * 16, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);

	printf ("D: %p\n", ptr);
	mprotect (ptr, getpagesize (), PROT_READ|PROT_WRITE);

	*(int*)ptr = 18;
	printf ("%d\n", *(int*)ptr);
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Actual results:

valgrind ./a.out
==25441== Memcheck, a memory error detector
==25441== Copyright (C) 2002-2009, and GNU GPL'd, by Julian Seward et al.
==25441== Using Valgrind-3.5.0-Debian and LibVEX; rerun with -h for copyright info
==25441== Command: ./a.out
==25441==
D: 0x4020000
==25441== Invalid write of size 4
==25441==    at 0x400620: main (in /raid/home/zovarga/a.out)
==25441==  Address 0x4020000 is not stack'd, malloc'd or (recently) free'd
==25441==
==25441== Invalid read of size 4
==25441==    at 0x40062A: main (in /raid/home/zovarga/a.out)
==25441==  Address 0x4020000 is not stack'd, malloc'd or (recently) free'd
==25441==
18
Comment 1 Zoltan Varga 2010-02-01 20:46:01 UTC
This is on debian unstable on amd64.
Comment 2 Tom Hughes 2010-02-01 22:17:36 UTC

*** This bug has been marked as a duplicate of bug 205541 ***