[Qt-interest] help tracking down memory corruption on Mac Qt 4.7.3 Cocoa (64 bit)
Paul Miller
paul at fxtech.com
Tue May 24 15:44:50 CEST 2011
On 5/23/2011 5:16 PM, Robert Escott wrote:
> These symptoms sound exactly like a problem I had earlier this month.
>
> My problem turned out to be nothing to do with the QWidget or QHash
> problems. It turned out to be a double deletion of one of the data
> members of my Model. I'd not properly implimented the asignment operator
> on one of the data members so incorrect referencing was causing data to
> be deleted. The model wasn't expecting this so it was trying to
> reference deleted data. That's when the random crashing occurred.
>
> Go through all your data members' destructors, copy constructors and
> assignments to double-check all the referencing and deletions are
> occurring correctly.
Thanks Dair for suggesting valgrind - it helped me narrow down the problem.
Valgrind reported several invalid writes to bools I had in a widget
subclass. It reported them as writes after an allocation of a certain
size. I guess the compiler was not aligning them properly or not
computing the size of the memory allocation for the class properly. I
moved the bool variables to the top of the list of member variables and
the problem went away. valgrind no longer reports invalid writes.
This problem didn't exist on Windows, nor in 32 bit mode on Mac, so I
suspect a bug in the 64 bit compiler. Unfortunately this happened with
gcc 4.2 and llvm 1.7. Spent literally 2 days tracking this one down. :-(
More information about the Qt-interest-old
mailing list