2

While running release build in Qt Creator get following error message:

The program has unexpectedly finished.
.....exe exited with code -1073740791

Runs successfully in debug mode in debugger. In another thread found that this is

0xc0000409 = STATUS_STACK_BUFFER_OVERRUN

error. Program and Qt was built with VS C++. Where the problem could be? Or should I run some profiler to check memory access?

Aleksey Kontsevich
  • 4,671
  • 4
  • 46
  • 101
  • first build your code with option: "treat warning as errors" (in gcc it is "-Wall") to catch any stupid problems. – Marek R Dec 04 '13 at 16:58

1 Answers1

3

When a program runs in debug, but crashes in release, it tends to be due to uninitialised variables. Debug builds, particularly running with a debugger, may clear the memory for you before use, so it can hide the problem. I suggest you start by checking for uninitialised variables.

If you're really stuck, change the configuration to build debug symbols for the release build, then when it crashes attach a debugger and see what the code is doing.

Alternatively, print out debug text to the console with qDebug at various points in your code and see if you can identify where the problem is from that.

TheDarkKnight
  • 27,181
  • 6
  • 55
  • 85
  • Have not found uninitialized variables. Can't attach debugger as it exits immediately. I've added std::cerr << "program start" << endl; output on program start - outputs nothing. – Aleksey Kontsevich Dec 04 '13 at 17:00
  • You can try placing a break in code at the start of your main function. In gcc/clang that would be: __asm__("int $3"); The syntax may be slightly different for VSC++. Once the break has been hit, you can then attach the debugger. There's more about this here: http://stackoverflow.com/questions/37299/xcode-equivalent-of-asm-int-3-debugbreak-halt – TheDarkKnight Dec 04 '13 at 17:15
  • Seems it even does not go to main(). Weird: works fine now on one machine after full clean/rebuild, still fails on another. – Aleksey Kontsevich Dec 05 '13 at 17:57
  • Check system logs and see if there's any clue there as to what's going wrong. – TheDarkKnight Dec 06 '13 at 08:40
  • Debugger shows it fails in QtXml4!QDomNode::toElement. But why it not fails in debug?! Tried to output trace to log, still no info... – Aleksey Kontsevich Dec 09 '13 at 22:57
  • Look around everything to do with your xml code; there's likely to be something getting used before being initialised. How are you outputting "trace to log" ? – TheDarkKnight Dec 10 '13 at 08:42
  • Own logger class with fprintf within – Aleksey Kontsevich Dec 10 '13 at 10:00
  • to a file and to stderr in case I logging error. Now only to a file. I even put try/catch in block where I think it fails - nothing, do not catch. May be some access violation error? Is there some good profiler ala valgrind in Windows for VS C++? – Aleksey Kontsevich Dec 10 '13 at 10:09
  • Sorry, not familiar with Windows alternative profiler, though it looks like it has been asked here: http://stackoverflow.com/questions/413477/is-there-a-good-valgrind-substitute-for-windows – TheDarkKnight Dec 10 '13 at 10:16
  • @AlekseyKontsevich This sounds to me like a missing DLL, especially the part about the program not entering main(). Check a couple things: 1) That any DLLs your program may use are in the working directory, and 2) that the working directory of your program is where you think it is (check your IDE's settings). – sleeparrow Jan 15 '14 at 01:45
  • I checked with DependencyWalker - all dlls are present. – Aleksey Kontsevich Jan 16 '14 at 02:43