Results 1 to 6 of 6

Thread: Release version crashes, debug version runs as expected

  1. #1
    Join Date
    Jul 2008
    Location
    East Coast, USA
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Release version crashes, debug version runs as expected

    Hi,

    I have a strange problem. I have an app that uses threads to do some lengthy computations (triggered by some user interaction). These threads can be manipulated by the user by further user interactions.

    When I compile the app in debug mode the application runs as expected - I can start one of these threads and then press keys to alter their operation. When I compile in release mode, however, trying to manipulate the thread causes an application crash.

    Has any one had this kind of issue before, does anyone have an idea of why debug and release would create different behaviors like this?

    I'm using QT4.1 on Mac OS X

    Thanks
    -Kaushik

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Release version crashes, debug version runs as expected

    You have somewhere "undefined behaviour".
    Undefined can mean: crashes now and then, or crashes in release but not debug build, or vice versa. So it is pure (bad) luck that the crash does not happen in the debug build.

    Likely causes:
    * thread not synced properly (a accesses to common data protected by a mutex?)
    * array bounds violation

    Try running your program through valgrind. Maybe you get a hint from there.

    HTH

  3. The following user says thank you to caduel for this useful post:

    kghose (2nd October 2008)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Release version crashes, debug version runs as expected

    It could be an uninitialized variable which gets initialized to a sane value in debug mode.
    J-P Nurmi

  5. #4
    Join Date
    Jan 2006
    Posts
    368
    Thanks
    14
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Release version crashes, debug version runs as expected

    This is called the Heisenberg Principle. It origins from physics (see the wikipedia entry: http://en.wikipedia.org/wiki/Uncertainty_principle). The idea is that when want to measure a system, you insert a probe to measure it, and thus you change the system. It applies to software as well (read the Popular culture part of the wikipedia entry for more "implementations" of this principle).

    The application crashes due to a race condition, you put a
    Qt Code:
    1. printf()
    To copy to clipboard, switch view to plain text mode 
    which changes the internal timings (or compile in debug mode, which might be slower, faster, or just different), different commands get scheduled differently - oops, no problem

    Now the fun part of my responce: good luck, you will need it.

  6. #5
    Join Date
    Aug 2008
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Release version crashes, debug version runs as expected

    I have a similar problem. Works on debug, but no on release. To make it special, this happens on linux. On windows it's the other way around. I've yet to find any reason for this behavior. My solution ends up being this:

    win32 {
    CONFIG += release
    }

    linux-g++ {
    CONFIG += debug
    }

    I also run strip on the app on linux to get a smaller size for it. It's not always 0s and 1s...

    Good luck, but don't wast to much time on this quest. It might not be worth it.

  7. #6
    Join Date
    Jul 2008
    Location
    East Coast, USA
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Thumbs up Solved

    Thanks for your replies guys.

    I solved it by basically going back and rewriting the thread more cleanly, so that its behavior to stochastic (i.e. user) input is more robust.

    I don't know what the exact problem was, but the code looks prettier now and, it works both in debug and release!

    -Kaushik

Similar Threads

  1. Qt designer plugin errors on OSX Leopard
    By mpotocnik in forum Qt Tools
    Replies: 10
    Last Post: 21st January 2008, 10:45
  2. Distributing QT application for Mac OS
    By mb0 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2007, 19:59
  3. Replies: 15
    Last Post: 21st April 2007, 18:46
  4. Replies: 6
    Last Post: 10th November 2006, 11:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.