|
From: Arndt M. <amu...@is...> - 2005-09-06 15:01:54
|
Hi all! Recently, I found that helgrind is reporting an error in C++ destructor code I couldn't explain. After investigating, I came to the solution. When the destructor of an object is called every destructor of its parents classes is called prior to actual releasing the memory associated with the object. The destructor of the super-class should only see the properties of its class and therefore the environment has to be changed in order to reflect this change in properties and virtual method pointers. This change is done by writing to a location in the object's memory, (that is marked shared read-only, no locks) hence resulting in a warning, because Helgrind does not know anything about objects and destructors and that accesses of an object's memory in its destructor can not result in a data race on itself. I wrote a small example programm exhibiting this bevahior. A solution would be, to set the objects memory to NEW upon entry of the destructor, therfore avoiding false reports. I did this with help of Aspect-C++, where the need to call VALRIND_HG_* in destructors might be expressed as an aspect, but I wonder, if it would be possible in the Helgrind tool itself without reducing the performance of the tool. Any suggestions? Greetings, Arndt |