[Interest] Windows segfault, but not on Linux

Konrad Rosenbaum konrad at silmor.de
Thu Nov 21 11:36:47 CET 2013


Hint: if your code is multi-threaded, behavior is radically different on Linux 
and Windows:

* which thread runs first differs on single-CPU (and sometimes multi-CPU) 
systems

* creating threads takes slightly longer on Windows, which may change some 
timing in accessing variables during thread startup

* Windows has no strong CPU-Core-Bias, meaning threads switch between cores 
much more often, causing subtle differences in delays

Hint 2: never assume something as innocuous as var++ is an atomic operation 
unless it is protected by a Mutex! My most recent hard-to-fix on-Windows-only 
crash was a race between refcnt++ and refcnt-- in a library that I didn't even 
write myself (libtcl).

You can catch these by sifting through tons of false positives of the drd and 
helgrind tools of valgrind (you can filter out anything that is caused by 
QMutex and QSemaphore as false positives).



	Konrad

On Thursday, Thursday 21 November 2013 at 10:12, William Hallatt wrote:
> Thanks for the input!
> 
> I have run it through valgrind before and didn't pick up anything weird,
> but I think I will have to investigate this route more thoroughly (I admit
> to doing some nasty raw pointer work with this guy, but the fact that it
> ran so smoothly on Linux made me think I had nailed all the issues).
> 
> Any amazing settings/valgrind options you prefer when valgrinding with
> QtCreator (or command line)?
> 
> PS Bo...I agree with you re system bugs, I am pretty sure the issue is on
> my side, but now to find it! :D
> 
> On 21 November 2013 10:19, Koehne Kai <Kai.Koehne at digia.com> wrote:
> > > -----Original Message-----
> > > From: interest-bounces+kai.koehne=digia.com at qt-project.org
> > > [mailto:interest-bounces+kai.koehne=digia.com at qt-project.org] On Behalf
> > 
> > Of
> > 
> > > Bo Thorsen
> > > Sent: Thursday, November 21, 2013 7:43 AM
> > > To: interest at qt-project.org
> > > Subject: Re: [Interest] Windows segfault, but not on Linux
> > > 
> > > Hi William,
> > > 
> > > Sounds like you have quite a nightmare of a bug there.
> > > 
> > > I don't have a solution for you, but I can tell you my starting points
> > 
> > for trying to
> > 
> > > figure this one out.
> > > 
> > > First is *always* this one: Have you run your application in valgrind?
> > 
> > I'd start with that  too, and here's why: Such 'weird' errors in
> > seemingly unrelated code paths are often enough a sign of a memory
> > corruption going on ... i.e. you're writing to invalid pointers etc
> > somewhere else in your code.
> > 
> > Regards
> > 
> > Kai
> > _______________________________________________
> > Interest mailing list
> > Interest at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131121/12611cfb/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131121/12611cfb/attachment.sig>


More information about the Interest mailing list