开发者

How can I investigate the source of an Access Violation that occurs on launching the app?

I´m new to C++ programing. I am compiling a Windows Application which compiles ok with just a few warnings, but when I launch it, it doesn´t even seem to start and returns an Access Violation 3 seconds into the run. When I try to debug it doesn´t even seem to get into the code, so I don´t know where to start looking for the problem.

Here is the info I have been able to retrieve from the debugger:

Building to ensure sources are up-to-date
Build succeeded
Selecting target: 
Debug
Adding source dir: C:\Documents and Settings\Christian Ekiza\Mis documentos\My Dropbox\Private Files\coding\juego_pruebas_01\juego_pruebas_01\
Adding source dir: C:\Documents and Setting开发者_如何学Gos\Christian Ekiza\Mis documentos\My Dropbox\Private Files\coding\juego_pruebas_01\juego_pruebas_01\
Adding file: bin\Debug\juego_pruebas_01.exe
Starting debugger: 
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Child process PID: 3328
Program received signal SIGSEGV, Segmentation fault.
In ?? () ()

and this is from the Call Stack

#0 00000000 0x000154e4 in ??() (??:??)
#1 00409198 __cmshared_create_or_grab() (../../../../gcc-4.4.1/libgcc/../gcc/config/i386/cygming-shared-data.c:140)
#2 00000000 0x0040131b in __gcc_register_frame() (??:??)
#3 00000000 0x0040a09b in register_frame_ctor() (??:??)
#4 00000000 0x00408f42 in __do_global_ctors() (??:??)
#5 00000000 0x00401095 in __mingw_CRTStartup() (??:??)
#6 00000000 0x00401148 in mainCRTStartup() (??:??)

And the CPU Registers end with a

'gs' register with a hex value '0x0'

I don't really know where to start looking for the problem. Anyone can help me out or point me in the right direction?

Note: I am using Code::Blocks


As you say it is a Windows application. Then, any issues with startup, I have found ADPlus very useful.

EDIT 2:

You may also check User Mode Process Dumper if ADPlus does not apply


See, if you have some global instance(s) of class with constructor - if error is raised in constructor and class is declared globally (bad thing to do btw) - you'll get sigsegv even before main(). If you have such classes - try to refactor your code to have them inside main (or other function) - it will be easier to debug.


Try the following free MS tools - both are great for debugging this kind of problem.

  • Application Verifier http://www.microsoft.com/downloads/en/details.aspx?familyid=c4a25ab9-649d-4a1b-b4a7-c9d8b095df18&displaylang=en

  • Gflags from Debugging Tools for Windows http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en


Sounds to me like one of your DLL dependencies can't be loaded or instantiated correctly.


Did you you compile with debug mode (-g) enabled?

Also seriously consider actually fixing the warnings. Most of the time they are actual problems in the code that should be resolved.

You should also try to see if this happens with a nearly empty main (comment out most/all of your code in main).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜