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

Josiah Bryan josiahbryan at gmail.com
Thu Jun 14 01:52:45 CEST 2012


On 6/13/12, André Pönitz <andre.poenitz at mathematik.tu-chemnitz.de> wrote:
> 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

Correct, no #ifdef's for debug mode - a few for Windows/Linux, but
that's about it.

>
>     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".

Perhaps - the thing is, these errors are not generated in Release mode
- e.g. no complains about instantiating a QApplication first, QWidget
doesn't complain about a QApplication before a QPaintDevice - given
that they are running the same code path, wouldn't these errors output
in Release mode as well?

>> 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'.

Granted. However, None of *my* code is executed prior to QApplications
creation - any global static objects are created using a static
::instance() model (check static pointer at call time, create if not
exists at that time) - sort of like a "pull" model to create any
needed global pointers.

The real problem here is that Qt Creator / Debugger doesn't even
bother to give a stack trace of where it stopped at - just the MSVC
error dialog, no stack trace. If it would just give some info about
*where* it stopped, I could trace it from there. As it sits now, I'm
flailing in the dark at more than 50K SLOC. Any thoughts as to why no
stack trace from the debugger?

>
> 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.

I'll double-check globals, but a stack trace is really what's needed
here anyway - debugger just says "Application exited with exit code
exit-code="03"" (Yes, I googled that - no, the only three results I
found did not help.)

Thanks for your help and advice!
-Josiah

-- 
Josiah Bryan
765-215-0511
josiahbryan at gmail.com



More information about the Interest mailing list