[Qt-interest] Replace Qt Allocator
David Walthall
walthall at wavefun.com
Wed Sep 16 22:47:40 CEST 2009
Eric Clark wrote:
> Our program uses a system allocator called nedmalloc. We override the
> new and delete operators to use this system allocator. However, after
> porting to Qt 4 we have ran into some issues with the QList class and
> it’s destructor. When the list is destructed, it attempts to free the
> memory created by the list, but nedfree() crashes because the memory was
> instantiated using the system allocator, malloc(). Here is the problem:
>
> The problem is indeed a violation of the ODR requirement in the ISO C++
> spec. For example in this line:
>
> QModelIndexList indexes = list->selectionModel()->selectedRows();
>
> QModelIndexList exists in the local binary due to being a templated type
> based on QList, therefore its destructor is called from the local binary
> where ::operator delete has been defined to invoke nedmalloc.
> Unfortunately the initial constructor of the list (selectedRows())
> exists in one of the Qt DLL binaries where ::operator new is defined to
> invoke the system allocator. Therefore the list is being constructed
> with the system allocator and destructed with nedmalloc - this obviously
> enough provokes a segfault as ODR is violated.
Did you take Thiago's advice and recompile Qt to use nedmalloc?
http://lists.trolltech.com/pipermail/qt-interest/2009-June/009114.html
David
More information about the Qt-interest-old
mailing list