[Qt-interest] Replace Qt Allocator
RZ
rz at univie.ac.at
Wed Sep 16 20:54:50 CEST 2009
Hi,
don't know if that helps - but we use TLSF (which is not so much faster
AFAIK but maybe we have slightly different use cases).
We also had problems with "strange" crashes - until a colleague found
out that we had to use a compiler switch (for thread enabling within TLSF).
hmm, maybe there's something like this....
RZ
> Hello All,
>
>
>
> 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.
>
>
>
> I was told by some guys on this interest board that I should build
> nedmalloc into Qt. However, after doing so, I still get the same error.
> What I did to build nedmalloc into Qt, was I modified the body of
> qFree(), qMalloc(), and qRealloc() to use nedfree(), nedmalloc(), and
> nedRealloc() respectively. This apparently was not enough to fix the
> problem. Could anyone tell me what else needs to be done? Do I need to
> override the new and delete operators in Qt as well? Are there any
> direct calls to malloc() in the code that I am unaware of?
>
>
>
> Any help with this would be greatly appreciated!
>
>
>
> Eric
>
>
>
More information about the Qt-interest-old
mailing list