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

On Thu, Oct 26, 2017 at 11:11 PM, Jason H <jh...@gmx.com[mailto:jh...@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.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to