|
From: Nicholas N. <nj...@ca...> - 2003-08-05 15:04:01
|
On 5 Aug 2003, Paul A. Clarke wrote:
> I'd suggest that these recent threads about Valgrind not
> detecting/reporting invalid write attempts to read-only memory are at
> least justifications for adding something either to the FAQ or to the
> documentation (section 2.12, "Limitations"?), or both.
>
> I could take a stab at it, if someone in the project thinks it
> worthwhile, and nobody volunteers. (I'm not an expert in the area, but
> this is probably only a couple of sentences, right?)
Yep... how about this:
Q. My program dies with a segmentation fault, but Valgrind doesn't give
any error messages before it, or none that look related.
A. The one kind of segmentation fault that Valgrind won't give any
warnings about is writes to read-only memory. Maybe your program is
writing to a static string like this:
char* s = "hello";
s[0] = 'j';
or something similar.
Seem reasonable?
----
I've said that it's very hard/impossible to add such read-only write
checking to Valgrind's memory checker (Memcheck) without adding much
complexity and slowing it down more. However, it would be pretty easy to
write a new skin that checks specifically for this. It could be used as a
backup for Memcheck -- when you get a seg fault that Memcheck doesn't
diagnose, you could run your program through the new skin and (hopefully)
it would tell you where you wrote to read-only memory.
All this assumes that read-only writes are the only seg fault-causing
operations that Valgrind doesn't watch out for. I think this is true, but
not 100% certain.
N
|