[Qt-interest] Replace Qt Allocator
Eric Clark
eclark at ara.com
Wed Sep 16 22:43:06 CEST 2009
> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of RZ
> Sent: Wednesday, September 16, 2009 1:55 PM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] Replace Qt Allocator
>
> 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....
Actually, there is, but we have already done that. We know with 100% assurance that the problem is in Qt with the constructor and destructor of the QList.
Thank You though!
>
> 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
> >
> >
> >
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list