|
From: Ron V. I. <van...@ca...> - 2006-03-08 20:03:52
|
I don't know if this is considered a bug in Valgrind or not but it is a
feature of Purify that Valgrind does not support. Valgrind appears to
ensure that newing code with [] match the deletes with []s, mallocs
match the frees and so on. However, it does not appear to catch when
you destruct something as the wrong type. eg, the following code
generates no errors from Valgrind and runs to completion with the
expected results:
#include <iostream>
class foo{
public:
virtual ~foo(){std::cout<<"In foo's destructor"<<std::endl;}
};
class bar{
public:
virtual ~bar(){std::cout<<"In bar's destructor"<<std::endl;}
};
int main()
{
bar* b = new bar;
foo* f = (foo*)b;
delete f;
}
This kind of code can often lead to heap corruption on our old MIPS
systems and, I would think, the same is likely true of Xeon EM64T
systems. Can this lead to heap corruption on Linux or was this simply a
problem in the older system?
--Ron
|