|
From: Henrik N. <hn...@ma...> - 2004-03-24 09:17:07
|
On Wed, 24 Mar 2004, RAMPARANY Fano FTRD/DIH/GRE wrote: > Does valgrind detect illegal access to statically allocated memory? Only if you pad the variable with inaccessible data. Normally the compiler packs static variables together in the data segment, so valgrin can not detect such misuse as for all valgrind knows you are accessing the next static variable.. (or more exactly some data in the static data segment of your application) You can however manually instrument your program to add suitable "red" zones arount suspectible variables just like valgrind automatically does on malloc:ed memory. See the "Client Requests" section in the memcheck chapter. But in many cases it is simpler to just allocate the variables with malloc instead as assays and pointers are semantically equivalent in C (except for sizeof).. converting to malloc also makes it possible for valgrind to guess what you intended to access in it's error report Regards Henrik |