Author Topic: GDB Debugging Segfault  (Read 14508 times)

Offline aerea

  • Single posting newcomer
  • *
  • Posts: 5
GDB Debugging Segfault
« on: January 10, 2009, 11:56:44 am »
Hi all,

I seem to be having a problem while debugging a small project.  If I have compile in Debug mode and select Start from the debug menu, the program exits with a segfault (expected).  However, if I place a single breakpoint anywhere in the project and then Start debugging, Code::Blocks itself gets a segfault.  Here is a full backtrace with the latest nightly (rev 5394) compiled with debug:

Code
...                                               
(gdb) run                                                                    
Starting program: /usr/local/bin/codeblocks                                  
[Thread debugging using libthread_db enabled]                                
Initialize EditColourSet .....                                              
[New Thread 0x7fffe9805950 (LWP 2293)]                                      
[New Thread 0x7fffe8b99950 (LWP 2294)]                                      
[New Thread 0x7fffe8398950 (LWP 2295)]                                      
[New Thread 0x7fffe7b97950 (LWP 2296)]                                      
...                          
[New Thread 0x7fffe12e6950 (LWP 2306)]                                          
Loading workspace "/home/aerea/GAMUT/Make/Unix/GAMUT.workspace"          
Loading project file...                                                        
Parsing project file...                                                        
Loading target Debug                                                            
Loading target Release                                                          
Loading project files...                                                        
55 files loaded                                                                
Done loading project in 8ms                                                    
Project's base path: /home/aerea/GAMUT/Make/Unix/                        
Project's common toplevel path: /home/aerea/GAMUT/                        
Loading project file...                                                        
Parsing project file...                                                        
Loading target Debug                                                            
Loading target Release                                                          
Loading project files...                                                        
85 files loaded                                                                
Done loading project in 10ms                                                    
Project's base path: /home/aerea/GAMUT/Make/Unix/                        
Project's common toplevel path: /home/aerea/GAMUT/                        
project data set for /home/aerea/GAMUT/GAMUT_OS/OS_LinThread.h            
project data set for /home/aerea/GAMUT/GAMUT_OS/OS_LinThread.cpp          
project data set for /home/aerea/GAMUT/GAMUT_OS/OS_MutexMgr.h            
project data set for /home/aerea/GAMUT/GAMUT_OS/OS_LinMutex.h            
project data set for /home/aerea/GAMUT/GAMUT_OS/OS_LinMutex.cpp          
Loading project file...                                                        
Parsing project file...                                                        
Loading target Debug                                                            
Loading target Release                                                          
Loading project files...                                                        
24 files loaded                                                                
...                               
[New Thread 0x7fffe0a0d950 (LWP 2307)]                                          
[Thread 0x7fffe0a0d950 (LWP 2307) exited]                                      
Add project GAMUT_Core in parsing queue                                        
Caching internal gcc dirs for adding to parser...                              
Caching GCC dir: /usr/include/c++/4.3                                          
Caching GCC dir: /usr/include/c++/4.3/x86_64-suse-linux                        
Caching GCC dir: /usr/include/c++/4.3/backward                                  
Caching GCC dir: /usr/local/include                                            
Caching GCC dir: /usr/lib64/gcc/x86_64-suse-linux/4.3/include                  
Caching GCC dir: /usr/lib64/gcc/x86_64-suse-linux/4.3/include-fixed            
Caching GCC dir: /usr/x86_64-suse-linux/include                                
Caching GCC dir: /usr/include                                                  
...                                               
Starting batch parsing                                                          
Parsing stage done (633 total parsed files, 19921 tokens in 0 minute(s), 0.921 seconds).
Updating class browser...                                                              
Class browser updated.                                                                  
[New Thread 0x7fffe0a0d950 (LWP 2310)]                                                  
[Thread 0x7fffe0a0d950 (LWP 2310) exited]                                              
found /home/aerea/GAMUT/Test/Test_SerialIO/Test_SerialIO.cpp                      
-------------- Build: Debug in Test_SerialIO ---------------
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Target is up to date.                                      
Scanned 0 files for #includes, cache used 35, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Scanned 0 files for #includes, cache used 0, cache updated 0
Nothing to be done.                                          

Switching layout to "Code::Blocks default"

Program received signal SIGSEGV, Segmentation fault.
0x00007fffe3dabcb2 in DebuggerGDB::DoDebug (this=0x19237c0) at ../../../src/include/cbstyledtextctrl.h:1343
Line number 1343 out of range; ../../../src/include/cbstyledtextctrl.h has 29 lines.                      
(gdb) bt                                                                                                  
#0  0x00007fffe3dabcb2 in DebuggerGDB::DoDebug (this=0x19237c0) at ../../../src/include/cbstyledtextctrl.h:1343
#1  0x00007ffff3f22120 in Manager::ProcessEvent (this=<value optimized out>, event=@0x7fffffffc8d0) at manager.cpp:169
#2  0x00007fffe404cee3 in CompilerGCC::NotifyJobDone (this=0x1731060, showNothingToBeDone=<value optimized out>)      
    at ../../../src/include/scripting/bindings/sc_base_types.h:3679                                                  
#3  0x00007fffe4052e03 in CompilerGCC::DoRunQueue (this=0x1731060)                                                    
    at ../../../src/include/scripting/bindings/sc_base_types.h:1189                                                  
#4  0x00007fffe4058300 in CompilerGCC::Build (this=0x1731060, target=<value optimized out>)                          
    at ../../../src/include/scripting/bindings/sc_base_types.h:2597                                                  
#5  0x00007fffe4043b46 in CompilerGCC::Build (this=0x1731060, target=<value optimized out>)                          
    at ../../../src/include/scripting/bindings/sc_base_types.h:2602                                                  
#6  0x00007fffe3da63cf in DebuggerGDB::EnsureBuildUpToDate (this=0x19237c0)                                          
    at ../../../src/include/cbstyledtextctrl.h:1002                                                                  
#7  0x00007fffe3dac4b0 in DebuggerGDB::Debug (this=0x19237c0) at ../../../src/include/cbstyledtextctrl.h:1046        
#8  0x00007ffff1f43c79 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&)  
    () from /usr/lib64/libwx_baseu-2.8.so.0                                                                          
#9  0x00007ffff1f44e54 in wxEventHashTable::HandleEvent(wxEvent&, wxEvtHandler*) ()                                  
   from /usr/lib64/libwx_baseu-2.8.so.0                                                                              
#10 0x00007ffff1f44f47 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#11 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#12 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#13 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#14 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#15 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#16 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#17 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
---Type <return> to continue, or q <return> to quit---                                                                
#18 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#19 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#20 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#21 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#22 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#23 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#24 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#25 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#26 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#27 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#28 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#29 0x00007ffff1f44ed0 in wxEvtHandler::ProcessEvent(wxEvent&) () from /usr/lib64/libwx_baseu-2.8.so.0                
#30 0x00007ffff2889000 in ?? () from /usr/lib64/libwx_gtk2u_core-2.8.so.0                                            
#31 0x00007ffff48c437d in g_closure_invoke () from /usr/lib64/libgobject-2.0.so.0                                    
#32 0x00007ffff48da07d in ?? () from /usr/lib64/libgobject-2.0.so.0                                                  
#33 0x00007ffff48db738 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0                                
#34 0x00007ffff48dbc63 in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
#35 0x00007ffff7a3907b in gtk_widget_activate () from /usr/lib64/libgtk-x11-2.0.so.0
#36 0x00007ffff793d4ed in gtk_menu_shell_activate_item () from /usr/lib64/libgtk-x11-2.0.so.0
#37 0x00007ffff793ef35 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#38 0x00007ffff7930388 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#39 0x00007ffff48c437d in g_closure_invoke () from /usr/lib64/libgobject-2.0.so.0
#40 0x00007ffff48d9d5b in ?? () from /usr/lib64/libgobject-2.0.so.0
#41 0x00007ffff48db5af in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
#42 0x00007ffff48dbc63 in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#43 0x00007ffff7a3379e in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#44 0x00007ffff7928cf3 in gtk_propagate_event () from /usr/lib64/libgtk-x11-2.0.so.0
#45 0x00007ffff7929e13 in gtk_main_do_event () from /usr/lib64/libgtk-x11-2.0.so.0
#46 0x00007ffff75ad20c in ?? () from /usr/lib64/libgdk-x11-2.0.so.0
#47 0x00007ffff44290db in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#48 0x00007ffff442c8ad in ?? () from /usr/lib64/libglib-2.0.so.0
#49 0x00007ffff442cddd in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0
#50 0x00007ffff792a227 in gtk_main () from /usr/lib64/libgtk-x11-2.0.so.0
#51 0x00007ffff2814918 in wxEventLoop::Run() () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#52 0x00007ffff28a2a1b in wxAppBase::MainLoop() () from /usr/lib64/libwx_gtk2u_core-2.8.so.0
#53 0x000000000042e4ab in CodeBlocksApp::OnRun (this=0x0) at appglobals.h:711
#54 0x00007ffff1eea17d in wxEntry(int&, wchar_t**) () from /usr/lib64/libwx_baseu-2.8.so.0
#55 0x000000000042e852 in main (argc=1, argv=0x7ffff107e048) at appglobals.h:232
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
aerea@EvilFae:~>

When I debug my application directly from gdb, I get the following:

Code
Program received signal SIGSEGV, Segmentation fault.
0x000000000040bd9e in OS_LinSerial::SigIOHandler (iSigno=29, sitInfo=0x7fffffffd360, vpContext=0x7fffffffd230)
    at /home/aerea/GAMUT/GAMUT_OS/OS_LinSerial.cpp:550
550         unsigned int uiMaxRead = s->uiBufferLength - s->uiCurrentBufferLength;
(gdb)

Is there some magical setting I'm missing?  It's very annoying when I lose changes I've made to my project because Code::Blocks itself crashed.  I would be glad to be of assistance with further bug reports.

Thanks.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: GDB Debugging Segfault
« Reply #1 on: January 10, 2009, 01:13:28 pm »
You can try to uncheck "Settings -> Compiler and debugger... -> Debugger settings -> Catch C++ exceptions".

If I have this option set, it leads to segfaults in C::B because of a null-pointer assertion.

I know where it happens, but not why.

And it seems to only happen on 64-bit systems (at least for me) not on 32-bit (tested on debian unstable 64-bit and kubuntu 8.10 32.bit).
And if I see right you are on a 64-bit system.

I had no time to do further investigations.

Offline aerea

  • Single posting newcomer
  • *
  • Posts: 5
Re: GDB Debugging Segfault
« Reply #2 on: January 11, 2009, 02:48:49 am »
That solved the problem.  Thank you!

I may have time in the near future to investigate this problem further so I might post back.

Offline Death Knight

  • Multiple posting newcomer
  • *
  • Posts: 18
  • Death here
    • DivFix++
Re: GDB Debugging Segfault
« Reply #3 on: February 09, 2009, 09:13:17 am »
Yeah!, Thanks, it helps a lot  :D