[Interest] Can't Debug on Windows 7: Invalid parameter passed to C runtime

André Pönitz andre.poenitz at mathematik.tu-chemnitz.de
Wed Jun 13 23:50:13 CEST 2012


On Wed, Jun 13, 2012 at 04:25:59PM -0400, Josiah Bryan wrote:
> I'm attempting to debug an odd problem wherein my program (http://
> code.google.com/p/dviz/) crashes when displaying certain UTF-8
> strings. That's not really why I'm emailing - the problem I'd like
> your help with is that I'm unable to run the program in "Debug" mode
> in Qt Creator on Windows 7. 
> 
> I've set the project in Qt Creator to the "Debug" build and tried to
> run it in the Debugger (F5). The program builds and launches -
> however, before the main UI can appear, an error dialog titled
> "Microsoft Visual C++ Runtime Library" appears giving the following
> error: "This application has requested the Runtime to terminate in an
> unusual way. Please contact the application's support team for more
> information."
> 
> Below the console output from Qt Creator. As you can guess, it does
> run correctly in "Release" mode in Qt Creator (just crashes when the
> user performs a certain UI action - hence why I want to run it in
> Debug mode. Note that it does not crash on linux in gdb or in release
> mode - so this is specific to Windows and the debugger in Qt Creator.)

Assuming that the "release" mode takes roughly the same code path
as the "debug" mode (i.e. no major #ifdef surgery in your code),
the problems that are indicated by the output

    QObject: Cannot create children for a parent that is in a different
    thread. [...]

    QCoreApplication::applicationFilePath: Please instantiate the
    QApplication object first [...]

    QWidget: Must construct a QApplication before a QPaintDevice

    Invalid parameter passed to C runtime function.

They would exist in "release" mode as well. So it does not run
"correctly" there, rather "by accident".

> You'll note there are comments in the console output below regarding
> constructing QApplication before QPaintDevice and other references to
> QApplication - well, I don't know why it's complaining about that,
> because QApplication is created on the second line of code to be
> executed in in main() - see
> http://code.google.com/p/dviz/source/browse/trunk/src/main.cpp#36 for
> proof.

The second line of 'main' is not the second line of code that ie
executed. There are things like constructions of global objects
that go before 'main'.

Start with tracking down global objects, avoid them, or at the
very least don't do anything that needs a fully constructed
Q[Core]Application. Check your thread creation and thread affinity
of your QObjects.

Andre'



More information about the Interest mailing list