Code::Blocks Forums
User forums => Help => Topic started by: ValeV on April 01, 2019, 11:44:50 am
-
Hey,
I am developing GUI program in CodeBlocks using mingw compiler with wxWidgets library. I had troubles running standalone .exe file to run application, becuase it crashed when I exited it (just in Release version, and not in Codeblocks IDE or debug version). I seemed to fix it by unchecking "Optimize even more (for speed) [-O2]" flag, under build options->compiler settings->compiler flags->optimization.
Is this something that is known and if yes, can I get some additional info on this? Any help on why this might be the problem?
-
It would be easier to help if you specify MinGW and wxWidgets versions, but in any case the problem does not seem related to C::B.
-
It would be easier to help if you specify MinGW and wxWidgets versions, but in any case the problem does not seem related to C::B.
True, it may be wxWidgets problem. That's why I made a thread on wxWidgets forum as well, asking for a possible explanation.
Anyway, mingw version: 6.3.0-1
wxWidgets: 3.1.2
-
Works in Debug mode but crashes in Release mode? Chances are very low that this is caused by a third party library or even the compiler and very high that it is caused by you :).
Probably a buffer overrun or something related.
-
I had crashes in release mode when clicking on comboboxes in property grids && the program was linked with wxWidgets 3.1.0 DLL. They didn't happen neither in debug mode nor with static linking, and they went away with wxWidgets 3.1.1 without changing the code. The compiler was TDM-GCC 5.1.0.
-
There was a few optimization bugs in wxWidgets headers; no idea when they got fixed.
This problem sounds like that problem.
Tim S.
-
Works in Debug mode but crashes in Release mode? Chances are very low that this is caused by a third party library or even the compiler and very high that it is caused by you :).
Probably a buffer overrun or something related.
It works in Release as well, when I remove said flag. Could removing the flag fix the error like buffer overrun?
-
Could removing the flag fix the error like buffer overrun?
It won't fix the issue, just hide it so it will bite you again in the future. Buffer overrun side effects depend heavily on memory layout, and it changes with optimization level, debug mode, statixc or dynamic linking and compiler versions.
-
Could removing the flag fix the error like buffer overrun?
It won't fix the issue, just hide it so it will bite you again in the future. Buffer overrun side effects depend heavily on memory layout, and it changes with optimization level, debug mode, statixc or dynamic linking and compiler versions.
But the program crashed even if I just opened and quickly closed it. I didn't do any other operations. How can buffer overrun happen?
-
Don't know without seeing the code. If it does not crash in debug mode you can't debug properly, so you can try instead inserting wxMessageBox calls in the program flow to see which one shows before the crash.
I just opened and quickly closed it
If it fails at closing may be a window is not properly destroyed. Anyway this is out of this forum's scope.
-
But the program crashed even if I just opened and quickly closed it. I didn't do any other operations. How can buffer overrun happen?
Why can't it happen if it's in the code that runs when you run the program. Buffer overruns are not the only thing that can mess up memory management. Memory allocations do that, too.
-
And use-after-free, very frequent when closing applications.
-
And use-after-free, very frequent when closing applications.
But the program crashed even if I just opened and quickly closed it. I didn't do any other operations. How can buffer overrun happen?
Why can't it happen if it's in the code that runs when you run the program. Buffer overruns are not the only thing that can mess up memory management. Memory allocations do that, too.
Thank you for suggestions. Though I still don't understand how "optimize even more" flag in CodeBlocks would hide/fix the problem?
-
Though I still don't understand how "optimize even more" flag in CodeBlocks would hide/fix the problem?
Optimization changes the memory layout of the program which can make some bugs crash the program. Or it crashes in different place. When you debug memory management crashes they often don't stop at the exact point of error, but later. Sometimes libraries can be blamed, because they force you to conform some ugly rules. I think wxwidgets is one of those, because as far as I know it has some kind of special memory management going on with smart pointers. In my opinion smart pointers should never have been added in C++, because it's just not the way C++ works. There is nothing wrong with manual memory management if it doesn't have bugs, obviously.
-
There is nothing wrong with manual memory management if it doesn't have bugs, obviously.
Human is a bug that cant be fixed ;D