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

2017-10-29 Thread Konstantin Shegunov
On Sat, Oct 28, 2017 at 3:57 PM, Elvis Stansvik wrote: > > Alright, then I misunderstood. Sorry about that! > I didn't mean to start a debate at all, and agree with everything you said. > No need for apologies, I'm not looking to place blame or start a feud, just trying to make clear what was m

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

2017-10-28 Thread Elvis Stansvik
2017-10-27 23:04 GMT+02:00 Konstantin Shegunov : > On Fri, Oct 27, 2017 at 7:43 PM, Elvis Stansvik wrote: >> >> The definition of reentrant that Qt's documentation uses is documented >> at http://doc.qt.io/qt-5/threads-reentrancy.html. >> >> It's a little different from the one used in for example

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

2017-10-27 Thread Konstantin Shegunov
On Fri, Oct 27, 2017 at 7:43 PM, Elvis Stansvik wrote: > > The definition of reentrant that Qt's documentation uses is documented > at http://doc.qt.io/qt-5/threads-reentrancy.html. > > It's a little different from the one used in for example the POSIX C API. > It's pretty much the same thing, ju

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

2017-10-27 Thread Elvis Stansvik
2017-10-27 20:51 GMT+02:00 Thiago Macieira : > On Friday, 27 October 2017 11:22:39 PDT Thiago Macieira wrote: >> 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#L208

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

2017-10-27 Thread Roland Hughes
On 10/27/2017 01:20 PM, interest-requ...@qt-project.org wrote: QMap isn't thread safe, so I don't think your use is guaranteed to be safe, even if you're only reading. You're right, in the formal sense of the word, but if there are no `mutable` members or `const_cast` usage a reentrant class

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

2017-10-27 Thread Thiago Macieira
On Friday, 27 October 2017 11:22:39 PDT Thiago Macieira wrote: > 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 Wrong link. I meant https://code.woboq.

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

2017-10-27 Thread Elvis Stansvik
2017-10-27 20:22 GMT+02:00 Thiago Macieira : > On Friday, 27 October 2017 11:14:35 PDT Elvis Stansvik wrote: >> 2017-10-27 19:03 GMT+02:00 Thiago Macieira : >> > 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 >>

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

2017-10-27 Thread Thiago Macieira
On Friday, 27 October 2017 11:14:35 PDT Elvis Stansvik wrote: > 2017-10-27 19:03 GMT+02:00 Thiago Macieira : > > 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 _i

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

2017-10-27 Thread Elvis Stansvik
2017-10-27 19:03 GMT+02:00 Thiago Macieira : > 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 yo

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

2017-10-27 Thread Thiago Macieira
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

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

2017-10-27 Thread Elvis Stansvik
2017-10-27 15:52 GMT+02:00 Jason H : >> Sent: Friday, October 27, 2017 at 6:44 AM >> From: "Konstantin Shegunov" >> On Fri, Oct 27, 2017 at 9:45 AM, Elvis Stansvik >> mailto:elvst...@gmail.com]> wrote: > >> > QMap isn't thread safe, so I don't think your use is guaranteed to be >> > safe, even i

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

2017-10-27 Thread Jason H
> Sent: Friday, October 27, 2017 at 6:44 AM > From: "Konstantin Shegunov" > On Fri, Oct 27, 2017 at 9:45 AM, Elvis Stansvik > mailto:elvst...@gmail.com]> wrote: > > QMap isn't thread safe, so I don't think your use is guaranteed to be safe, > > even if you're only reading.   > You're right, in

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

2017-10-27 Thread Jason H
Wow. Good call. Thanks Konstantin and Bjorn! It now works as expected.    Sent: Friday, October 27, 2017 at 5:15 AM From: "Björn Piltz" To: "Jason H" Cc: "interestqt-project.org" Subject: Re: [Interest] QMap crash when using QtConcurrent::blockingMapped()

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

2017-10-27 Thread Konstantin Shegunov
On Fri, Oct 27, 2017 at 9:45 AM, Elvis Stansvik wrote: > > QMap isn't thread safe, so I don't think your use is guaranteed to be > safe, even if you're only reading. > You're right, in the formal sense of the word, but if there are no `mutable` members or `const_cast` usage a reentrant class can

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

2017-10-27 Thread Björn Piltz
> > I'm wondering if there isn't a reentrancy issue in QMap. > Almost. QMap works as it should if you only call const members, but as Konstantin said operator[] on a non-const instance is a mutating function. I am pretty sure your problems will go away if you declare operator() as const. Then, t

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

2017-10-26 Thread Elvis Stansvik
Den 27 okt. 2017 8:45 fm skrev "Elvis Stansvik" : Den 26 okt. 2017 10:11 em skrev "Jason H" : This is the first time I'm trying to use QMap with QtConcurrent, and blockingMapped(). It sometimes works, sometimes doesn't. I've created a minimal test case that seems to crash in the same way. It see

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

2017-10-26 Thread Elvis Stansvik
Den 26 okt. 2017 10:11 em skrev "Jason H" : This is the first time I'm trying to use QMap with QtConcurrent, and blockingMapped(). It sometimes works, sometimes doesn't. I've created a minimal test case that seems to crash in the same way. It seems to crash in varying places. namely: qmap.h: temp

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

2017-10-26 Thread Jason H
    Sent: Thursday, October 26, 2017 at 4:58 PM From: "Konstantin Shegunov" To: "Jason H" Cc: "interestqt-project.org" Subject: Re: [Interest] QMap crash when using QtConcurrent::blockingMapped() On Thu, Oct 26, 2017 at 11:11 PM, Jason H mailto:jh...@gmx.c

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

2017-10-26 Thread Konstantin Shegunov
On Thu, Oct 26, 2017 at 11:58 PM, Konstantin Shegunov wrote: > e.g. using `at()` instead of `[]` > Read as `value()` instead of `[]` ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest

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

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

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

2017-10-26 Thread Jason H
This is the first time I'm trying to use QMap with QtConcurrent, and blockingMapped(). It sometimes works, sometimes doesn't. I've created a minimal test case that seems to crash in the same way. It seems to crash in varying places. namely: qmap.h: template inline bool qMapLessThanKey(const Key