
Gennadiy Rozental wrote:
Gennadiy Rozental wrote:
Rush Manbert
writes: Now I have gone back and read the original thread about valgrind complaints. I see that Gennadiy is rather adamant about not changing the code.
I am not adamant. I just want to understand what is wrong and need some time to look deeper. I plan to look into this Friday/Saturday.
Genandiy
P.S. Does anyone have vmware image for the system where I can easily reproduce this?
Ok. I was able to get hold of freebsd 64 bit image and reproduce this.
Further investigation uncovered that the issue with statement:
delete (test_case*)tu.second;
is not the non-virtual destructor of class test_unit, but the fact that compiler decides to evaluate the expression tu.second twice: once before calling the destructor and once before calling free. By the type the destructor is called tu is invalid.
Not sure what is so specific about 64 bit, but i believe the issues should be resolved (by caching the value before delete statement).
Hello Gennadiy Great that you finally had the time to investigate this issue. I have two remarks about your analysis: 1) Why are you insisting on casting tu.second to test_case*? Actually you want your derived class destroyed but tu.second is a base class pointer of type test_unit*. You can simply call "delete tu.second" if the test_unit destructor is virtual. The whole casting thing is in my opinion just a workaround for not making the destructor virtual. 2) I am seeing the problem on 32Bit Intel Linux as well, so it is not restricted to 64Bit. Regards, Peter.