[Interest] QMap crash when using QtConcurrent::blockingMapped()

Jason H jhihn at gmx.com
Fri Oct 27 03:37:00 CEST 2017


 
 

Sent: Thursday, October 26, 2017 at 4:58 PM
From: "Konstantin Shegunov" <kshegunov at gmail.com>
To: "Jason H" <jhihn at gmx.com>
Cc: "interestqt-project.org" <interest at qt-project.org>
Subject: Re: [Interest] QMap crash when using QtConcurrent::blockingMapped()

On Thu, Oct 26, 2017 at 11:11 PM, Jason H <jhihn at gmx.com[mailto:jhihn at gmx.com]> wrote:It sometimes works, sometimes doesn't.
 
Smells like a race.
 But in my software it seems to come from line 42:
QList<QVector3D> hp = haystack_points[haystack_item];
 
This may be a write operation, beware of operator [] with maps, notice at the ends of the docs:

"If the map contains no item with key key, the function inserts a default-constructed value into the map with key key, and returns a reference to it."

My advice is to declare your members in `PointsCompare` as const and take it from there. The compiler will complain, but changing the access (e.g. using `at()` instead of `[]`) to your members should fix it.
 Maybe my use of a class with mapped() is wrong?
Not that I could see.
 
Well, remember that haystack_item is coming from search_keys which is the keys of the kaystack, so it *should* not be doing any writes. Still I will give it a go.

The errors I got were about double-free or a heap integrity checksum not matching. I'm wondering if there isn't a reentrancy issue in QMap.




More information about the Interest mailing list