[Interest] Windows segfault, but not on Linux

William Hallatt goblincoding at gmail.com
Thu Nov 21 17:55:13 CET 2013


I think I found the problem, thanks to everybody who contributed!

Out of interest, it turns out that:

   1. I DID have slots that were connected to two different timers, the
   first resulted in a sequence of events that deleted and nulled a bunch of
   pointers, the second resulted in a sequence of steps that ended up with
   other objects querying the deleted pointers (via reference double pointers)
   before acting on the results (if valid, do stuff, the usual)
   2. Another (intense) valgrind run and I found the little bastard!
   (Invalid read of size 8...)

My conclusion is that I was lucky on Linux :P

OK, more seriously though (and this is purely based on possibly faulty
deduction on my part) is that either:

   1. The sequences triggered by the slot mechanism were executed as
   intended and EXACTLY as they should have been on Linux, hence no problems
   there.  The multi-core Windows OS may or may not have executed the various
   steps in a way that resulted in a sequence where (a) object gets deleted
   (b) reference pointer is checked for validity and found valid (c) object
   gets nulled (d) suddenly reference is corrupt (as opposed to (a) object is
   deleted (b) object is nulled (c) reference is checked and found to be
   invalid (d) reference isn't acted on)
   2. Linux didn't recycle the deleted memory as quickly as Windows and I
   was simply lucky in that the object, although deleted, was still in memory
   when accessed via reference pointer.

I have absolutely no idea if the above reasoning holds any water, so once
more, please feel free to educate if you can.

Oh, and I sorted it out (touch wood, I will test properly again tomorrow)
by replacing the Object* ptr and Object** refPtrs with shared_ptr and
weak_ptr respectively.

Thanks again for everyone's willingness to help, I appreciate it immensely.

William.


On 21 November 2013 13:39, Stephen King <Stephen.King at domino-uk.com> wrote:

> > Sent: 21 November 2013 09:12
> > To: Koehne Kai
> > Cc: interest at qt-project.org
> > Subject: Re: [Interest] Windows segfault, but not on Linux
> >
> > 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
> >
> >
>
> Hi,
>
> We had a similar problem when going the other way (Windows to Linux) which
> was caused by some of our code (wrongly) relying on the order that slots
> were called in. When we moved to Linux the order changed and caused some
> very weird crashes.
>
> Steve
> **************************************************** Visit our website at
> http://www.domino-printing.com**************************************************** This Email and any
> files transmitted with it are intended only for the person or entity to
> which it is addressed and may contain confidential and/or privileged
> material. Any reading, redistribution, disclosure or other use of, or
> taking of any action in reliance upon, this information by persons or
> entities other than the intended recipient is prohibited. If you are not
> the intended recipient please contact the sender immediately and delete the
> material from your computer. E-mail may be susceptible to data corruption,
> interception, viruses and unauthorised amendment and Domino UK Limited does
> not accept liability for any such corruption, interception, viruses or
> amendment or their consequences.
> **************************************************** Domino UK Limited.
> Registered in England. Registered Number:1750201. Registered Office
> Address: Trafalgar Way, Bar Hill, Cambridge, CB23 8TU.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131121/889f46b8/attachment.html>


More information about the Interest mailing list