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

Elvis Stansvik elvstone at gmail.com
Fri Oct 27 20:38:33 CEST 2017


2017-10-27 20:22 GMT+02:00 Thiago Macieira <thiago.macieira at intel.com>:
> On Friday, 27 October 2017 11:14:35 PDT Elvis Stansvik wrote:
>> 2017-10-27 19:03 GMT+02:00 Thiago Macieira <thiago.macieira at intel.com>:
>> > On Friday, 27 October 2017 09:43:57 PDT Elvis Stansvik wrote:
>> >> Reentrant in the object oriented context of Qt means: It's safe to
>> >> call member functions from different threads _if_ the calls are made
>> >> on different instances.
>> >>
>> >> In your case you were making calls on the same instance.
>> >
>> > Calling const functions on the same instance is safe, provided no other
>> > threads are calling non-const functions.
>> >
>> > He was calling a non-const function.
>>
>> Alright. Thanks for clarifying. Is that a guarantee that holds for all
>> classes marked reentrant in Qt? (that const functions are safe even
>> when called on the same instance)
>
> I can't say for sure. Most of them will be like that, and definitely all the
> containers.
>
> There may be a few bugs here and there, code that does const_cast and needs to
> be fixed.
>
>> If so, maybe the docs page I linked should be updated to mention this [1].
>>
>> I thought that Qt wanted to reserve the right to do thread unsafe
>> stuff even in const functions, and that was the reason for the
>> definition of reentrant explained there.
>
> I will reject any change that tries to do that. But we may still have some of
> them lying around. For example:
>
> https://github.com/qt/qt/blob/4.8/src/corelib/global/qglobal.h#L2088-L2090
>

Alright, yes it would of course be bad practice and you'll do right to
reject such nonsense.

Just wanted to give Jason a heads up that the definition of reentrant
that's in Qt's docs does not guarantee it, even if it's very likely to
be practically safe for the majority of classes.

Elvis

> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list