Bug 198397 - please support memcheck annotations for benign out of bound accesses
Summary: please support memcheck annotations for benign out of bound accesses
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.5 SVN
Platform: Unlisted Binaries Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-30 10:09 UTC by Konstantin Serebryany
Modified: 2009-06-30 15:48 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
unittest (867 bytes, text/x-c++src)
2009-06-30 10:12 UTC, Konstantin Serebryany
Details
approximate patch (6.75 KB, patch)
2009-06-30 10:13 UTC, Konstantin Serebryany
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Serebryany 2009-06-30 10:09:00 UTC
Summary: 
It would be nice to support memcheck annotations (client requests) that allow to mark intentional out of bound accesses and accesses to uninitialized memory as benign. 

Proposed syntax: 

Primary annotations: 
VALGRIND_IGNORE_READS_BEGIN()
VALGRIND_IGNORE_READS_END()
VALGRIND_IGNORE_WRITES_BEGIN()
VALGRIND_IGNORE_WRITES_END()

derived annotations: 
VALGRIND_UNCHECKED_MEM_READ(ptr)
VALGRIND_UNCHECKED_MEM_WRITE(lhs_ptr, rhs)

Detailed discussion: http://thread.gmane.org/gmane.comp.debugging.valgrind.devel/7375/focus=7377

an approximate patch and a unittest attached.
Comment 1 Konstantin Serebryany 2009-06-30 10:12:43 UTC
Created attachment 34933 [details]
unittest
Comment 2 Konstantin Serebryany 2009-06-30 10:13:25 UTC
Created attachment 34934 [details]
approximate patch
Comment 3 Julian Seward 2009-06-30 15:48:19 UTC
Re patch #3, that is going to add a minimum of two instructions
(cmpb $0, $ignore_reads; jcond ...) to all fast paths.  Ungood.

Here's an alternative suggestion: don't mess with the fast-case
handlers.  Instead, move the logic into MC_(record_address_error).
That means we only pay the cost of it for memory accesses which
do cause an error, instead of on all accesses.

In fact, see function MC_(in_ignored_range) called at top of
MC_(record_address_error).  A mechanism like this kind-of
already exists, in order to support the --ignore-ranges flag
for memcheck.

Although I should point out the resulting semantics are a bit different.