Author Topic: Debugging assistance with segfault on FreeBSD  (Read 7441 times)

elvstone

  • Guest
Debugging assistance with segfault on FreeBSD
« on: August 08, 2005, 01:25:19 pm »
I've just successfully compiled C::B CVS (VERSION_1_0 branch) on FreeBSD 5.4 (wxWidgets 2.6.0 Unicode), and right now I'm trying to debug a segmentation fault I'm getting on startup. I could use some help. Here's an excerpt from my debugging session:

elvis@square$ LD_LIBRARY_PATH=. gdb codeblocks.exe
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) run
Starting program: /usr/home/elvis/Desktop/Download/cb/devel/codeblocks.exe

(codeblocks.exe:14250): Gtk-CRITICAL **: gtk_pixmap_new: assertion `val != NULL' failed

(codeblocks.exe:14250): Gtk-CRITICAL **: gtk_box_pack_start: assertion `GTK_IS_WIDGET (child)' failed

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 100178)]
0x28e1260a in gtk_widget_show () from /usr/X11R6/lib/libgtk-x11-2.0.so.600
(gdb) bt
#0  0x28e1260a in gtk_widget_show () from /usr/X11R6/lib/libgtk-x11-2.0.so.600
#1  0x284e122e in wxNotebook::SetPageImage () from /usr/X11R6/lib/libwx_gtk2u_core-2.6.so.0
#2  0x2886f216 in MessageManager::DoAddLog (this=0x82b8a00, type=mltLog, log=0x8317400) at sdk/messagemanager.cpp:213
#3  0x2886e296 in MessageManager (this=0x82b8a00, parent=0x813c000) at sdk/messagemanager.cpp:90
#4  0x2886d4b8 in MessageManager::Get (parent=0x813c000) at sdk/messagemanager.cpp:47
#5  0x2886c669 in Manager::GetMessageManager (this=0x82bb8d0) at sdk/manager.cpp:233
#6  0x2886bd5b in Manager::Get (appWindow=0x813c000, notebook=0x82a6400) at sdk/manager.cpp:54
#7  0x08062cad in MainFrame::CreateIDE (this=0x813c000) at src/main.cpp:449
#8  0x08061baf in MainFrame (this=0x813c000, parent=0x0) at src/main.cpp:366
#9  0x0805a047 in CodeBlocksApp::InitFrame (this=0x80c8180) at src/app.cpp:176
#10 0x0805a4c1 in CodeBlocksApp::OnInit (this=0x80c8180) at src/app.cpp:249
#11 0x0805cae0 in wxAppConsole::CallOnInit (this=0x80c8180) at app.h:87
#12 0x286dd67a in wxEntry () from /usr/X11R6/lib/libwx_baseu-2.6.so.0
#13 0x286dd756 in wxEntry () from /usr/X11R6/lib/libwx_baseu-2.6.so.0
#14 0x08059733 in main (argc=1, argv=0xbfbfeac0) at src/app.cpp:297

.. okay, so something is wrong with the wxNotebook::SetPageImage() call, lets see..

(gdb) c
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) b sdk/messagemanager.cpp:213
No source file named sdk/messagemanager.cpp.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (sdk/messagemanager.cpp:213) pending.
(gdb) run
Starting program: /usr/home/elvis/Desktop/Download/cb/devel/codeblocks.exe
Breakpoint 2 at 0x2886f1f0: file sdk/messagemanager.cpp, line 213.
Pending breakpoint "sdk/messagemanager.cpp:213" resolved
[Switching to Thread 1 (LWP 100116)]

Breakpoint 2, MessageManager::DoAddLog (this=0x82b8a00, type=mltLog, log=0x8317400) at sdk/messagemanager.cpp:213
213         SetPageImage(log->GetPageIndex(), 0); // set default page image
(gdb) p log->GetPageIndex()
$1 = 0
(gdb)

..so this shows that SetPageImage() would be called with 0 and 0 as arguments. That's not a problem, right? The weird thing is that if I put a breakpoint at line 86, which is where the MessageManager gets its wxImageList assigned, it is never reached (even though this is in the constructor!):

(gdb) c
Continuing.

(codeblocks.exe:14256): Gtk-CRITICAL **: gtk_pixmap_new: assertion `val != NULL' failed

(codeblocks.exe:14256): Gtk-CRITICAL **: gtk_box_pack_start: assertion `GTK_IS_WIDGET (child)' failed

Program received signal SIGSEGV, Segmentation fault.
0x28e1260a in gtk_widget_show () from /usr/X11R6/lib/libgtk-x11-2.0.so.600
(gdb) l sdk/messagemanager.cpp:86
81          prefix = ConfigManager::Get()->Read(_T("data_path")) + _T("/images/");
82          bmp.LoadFile(prefix + _T("edit_16x16.png"), wxBITMAP_TYPE_PNG);
83          images->Add(bmp);
84          bmp.LoadFile(prefix + _T("contents_16x16.png"), wxBITMAP_TYPE_PNG);
85          images->Add(bmp);
86          AssignImageList(images);
87
88          m_Logs.clear();
89          m_LogIDs.clear();
90          DoAddLog(mltLog, new SimpleTextLog(this, _("Code::Blocks")));
(gdb) b sdk/messagemanager.cpp:86
Breakpoint 3 at 0x2886d941: file sdk/messagemanager.cpp, line 86.
(gdb) run
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /usr/home/elvis/Desktop/Download/cb/devel/codeblocks.exe
[Switching to Thread 1 (LWP 100172)]

Breakpoint 2, MessageManager::DoAddLog (this=0x82b8a00, type=mltLog, log=0x8317400) at sdk/messagemanager.cpp:213
213         SetPageImage(log->GetPageIndex(), 0); // set default page image
(gdb)

..How can this be? DoAddLog() is only ever called from MessageManager itself, which means it must have been instantiated. But line 86 is never reached before the segmentation fault occurs! What am I missing.

Thankful for any help, I really want to get C::B running on FreeBSD.

Aron Stansvik
« Last Edit: August 08, 2005, 01:31:45 pm by elvstone »

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: Debugging assistance with segfault on FreeBSD
« Reply #1 on: August 08, 2005, 01:38:45 pm »
Did you run update.sh script after compiling C::B CVS?
this space is for rent

elvstone

  • Guest
Re: Debugging assistance with segfault on FreeBSD
« Reply #2 on: August 08, 2005, 01:52:38 pm »
Hm. I did. But now that I ran it again. I realized that some of the cp commands failed, probably due to different behavior of cp on FreeBSD (output below).. need to investigate. This might very well be it!


Packing core UI bitmaps
Packing plugins UI bitmaps
Copying files
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory
usage: cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src target
       cp [-R [-H | -L | -P]] [-f | -i | -n] [-pv] src1 ... srcN directory
Stripping debug info from output tree
Creating launch-scripts

elvstone

  • Guest
Re: Debugging assistance with segfault on FreeBSD
« Reply #3 on: August 08, 2005, 02:03:44 pm »
Okay. That was it. I was running from the devel/ directory, and the mkdir -p commands in the update script only created some of the required directories in the output/ directory.. Ok. now it's running but I need to debug some other problems, there's something seriously wrong with how the text is displayed in the editor component. I'll investigate..