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.
Created attachment 34933 [details] unittest
Created attachment 34934 [details] approximate patch
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.