Author Topic: App crashes on run  (Read 4365 times)

Offline ValeV

  • Multiple posting newcomer
  • *
  • Posts: 23
App crashes on run
« on: January 16, 2019, 02:53:34 pm »
hey,

I am new to c++, cb and wxwidgets. I am messing with tutorials (http://wiki.codeblocks.org/index.php/WxSmith_tutorials) and now and then when I run my application it instantly crashes.

In recent example, when I got this crash, I used ctrl+z to go back to start, rebuilt it and ran it, and still got the crash.

Full log:
    1. Rebuild:
Code
-------------- Clean: Release in Tutorial_2 (compiler: GNU GCC Compiler)---------------

Cleaned "Tutorial_2 - Release"

-------------- Build: Release in Tutorial_2 (compiler: GNU GCC Compiler)---------------

mingw32-g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\M0097932\Desktop\firstTest\Tutorial_2\wx_pch.h -o wx_pch.h.gch\Release_wx_pch_h_gch
windres.exe -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu  -J rc -O coff -i C:\Users\M0097932\Desktop\FIRSTT~1\TUTORI~1\resource.rc -o obj\Release\resource.res
mingw32-g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\M0097932\Desktop\firstTest\Tutorial_2\Tutorial_2App.cpp -o obj\Release\Tutorial_2App.o
mingw32-g++.exe -Wall -pipe -mthreads -Winvalid-pch -include wx_pch.h -D__GNUWIN32__ -D__WXMSW__ -DWXUSINGDLL -DwxUSE_UNICODE -DWX_PRECOMP -O2 -IC:\wxWidgets-3.1.2\include -IC:\wxWidgets-3.1.2\lib\gcc_dll\mswu -c C:\Users\M0097932\Desktop\firstTest\Tutorial_2\Tutorial_2Main.cpp -o obj\Release\Tutorial_2Main.o
mingw32-g++.exe -LC:\wxWidgets-3.1.2\lib\gcc_dll -o bin\Release\Tutorial_2.exe  obj\Release\Tutorial_2App.o obj\Release\Tutorial_2Main.o obj\Release\resource.res -s  -mthreads  -lwxmsw31u -mwindows
Output file is bin\Release\Tutorial_2.exe with size 95.50 KB
Process terminated with status 0 (0 minute(s), 7 second(s))
0 error(s), 0 warning(s) (0 minute(s), 7 second(s))

    2. Debug:
Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Release
Adding source dir: C:\Users\M0097932\Desktop\firstTest\Tutorial_2\
Adding source dir: C:\Users\M0097932\Desktop\firstTest\Tutorial_2\
Adding file: C:\Users\M0097932\Desktop\firstTest\Tutorial_2\bin\Release\Tutorial_2.exe
Changing directory to: C:/Users/M0097932/Desktop/firstTest/Tutorial_2/.
Set variable: PATH=.;C:\wxWidgets-3.1.2\lib\gcc_dll;C:\MinGW\bin;C:\MinGW;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\7-Zip;C:\Program Files\doxygen\bin
Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/Users/M0097932/Desktop/firstTest/Tutorial_2/bin/Release/Tutorial_2.exe
done
Setting breakpoints
Reading symbols from C:\Users\M0097932\Desktop\firstTest\Tutorial_2\bin\Release\Tutorial_2.exe...(no debugging symbols found)...done.
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 6988
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()


I google "segmentation fault" and it seems pretty abstract error - some problem happened with memory.

How can I fix the project without making a new one from scratch?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: App crashes on run
« Reply #1 on: January 16, 2019, 04:14:51 pm »
Select the debug target from the drop down menu near the build button and try the debugger again. Then the debugger will show youwhere the segfault occured

Offline ValeV

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: App crashes on run
« Reply #2 on: January 18, 2019, 08:42:53 am »
Select the debug target from the drop down menu near the build button and try the debugger again. Then the debugger will show youwhere the segfault occured

Thank you. In debugger window I get:

Code
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Release
Adding source dir: C:\Users\M0097932\Desktop\firstTest\Tutorial_2\
Adding source dir: C:\Users\M0097932\Desktop\firstTest\Tutorial_2\
Adding file: C:\Users\M0097932\Desktop\firstTest\Tutorial_2\bin\Release\Tutorial_2.exe
Changing directory to: C:/Users/M0097932/Desktop/firstTest/Tutorial_2/.
Set variable: PATH=.;C:\wxWidgets-3.1.2\lib\gcc_dll;C:\MinGW\bin;C:\MinGW;C:\ProgramData\Anaconda3;C:\ProgramData\Anaconda3\Library\mingw-w64\bin;C:\ProgramData\Anaconda3\Library\usr\bin;C:\ProgramData\Anaconda3\Library\bin;C:\ProgramData\Anaconda3\Scripts;C:\ProgramData\Oracle\Java\javapath;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\TortoiseGit\bin;C:\Program Files\Git\cmd;C:\Program Files\7-Zip;C:\Program Files\doxygen\bin
Starting debugger: C:\MinGW\bin\gdb.exe -nx -fullname -quiet  -args C:/Users/M0097932/Desktop/firstTest/Tutorial_2/bin/Release/Tutorial_2.exe
done
Setting breakpoints
Reading symbols from C:\Users\M0097932\Desktop\firstTest\Tutorial_2\bin\Release\Tutorial_2.exe...(no debugging symbols found)...done.
Debugger name and version: GNU gdb (GDB) 7.6.1
Child process PID: 3240
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()

In Call Stack window I get:
Nr  Address     Function
0    0x61fea9    ?? 0
1                     ?? 0


What can I gather from this?

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: App crashes on run
« Reply #3 on: January 18, 2019, 09:28:00 am »
You need to select the Debug target. In the fourth line of the log you posted clearly states "Release".

Offline ValeV

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: App crashes on run
« Reply #4 on: January 18, 2019, 10:07:00 am »
You need to select the Debug target. In the fourth line of the log you posted clearly states "Release".

I dont have debug target, I didnt choose it when I made the project. So there is nothing that can be done? I mean, the project is not important, it's for me to understand how to work with CB and wxWidgets.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1553
Re: App crashes on run
« Reply #5 on: January 18, 2019, 04:20:57 pm »
You can convert the release target in a debug one activating generation of debugging symbols (option -g) and deactivating optimization (option -O2) in Project->Build options->Compiler settings->Compiler flags. You can also define NDEBUG in the #defines tab.

After changing these options you must rebuild the project (Build->Rebuild) before clicking the debug tool button.

While learning you should always generate a debug target.