Re: Segmentation fault in gtk2-perl-application

On Mar 31, 2005, at 4:20 PM, Stephan Brunner wrote:

Am Donnerstag 31 März 2005 04:33 schrieb muppet:
What versions of gtk+, glib, Gtk2, and Glib are you using?  what

I run Debian Sarge on x86; that came with gtk+ 2.6.2, glib 2.6.3, Gtk2 and
Glib 1.062. My personal debug-build of Gtk2 and Glib is 1.080.

on Fedora 2 with glib-2.4.0, gtk+ 2.4.7, Glib/Gtk2 1.080, i can't seem to reproduce the failure with your script.

same results in my cvs sandbox, which has glib-2.6.5 and gtk+ 2.6.4.

Beyond that, seeing the code is really going to be necessary.

Here it is -- to my own surprise, I was able to delete pretty much everything of my script and still get the segfault. What's left is not more than a very basic gtk2-app that does nothing else than prompt for a directory if you
select File->open directory or hit Ctrl-O:

what about this even shorter version? does it still exhibit the same behavior? (i merely replaced the UIManager gui with a simple window containing a button. if this one still crashes, we can rule out UIManager interactions...)

use warnings;
use strict;
use Gtk2 '-init';

my $window = Gtk2::Window->new;
$window->signal_connect (destroy => sub { Gtk2->main_quit; });

my $button = Gtk2::Button->new ('click me');
$button->signal_connect (clicked => \&loadDir);
$window->add ($button);


sub loadDir {
    print "Entering sub loadDir...\n";
    my $dlg = Gtk2::FileChooserDialog->new('Select directory', undef,
         'gtk-cancel' => 'cancel',
         'gtk-open' => 'ok');
    my $response = $dlg->run();
    if ($response ne 'ok') {
        print "You aborted.\n";
    else {
        print 'You selected: >' . $dlg->get_filename . "<\n";

    print "Leaving sub loadDir...\n";

The probability of getting the segfault depends on the directory selected -- there is a folder in my $HOME that almost always results in the segfault.

what is the name of that folder? does its name (or the names of its children) contain any non-ascii characters? how many files are in that folder?

For the above sample-script, I created a new backtrace which is much shorter
than the one I sent yesterday:

(gdb) bt
#0 0x40769d9c in gtk_path_bar_get_type () from /usr/lib/

the valgrind output confirms that there's memory corruption, specifically, using freed memory on the heap. the fun part will be tracking down where and why that actually occurs...

The above script is so short and simple that I am stunned it can segfault.

heh. try a script that merely creates a common dialog (one-liner) but doesn't first call Gtk2->init. it blows up almost immediately because pango isn't initialized. ;-)

I think it worked on the Wiley Coyote model of project management - if
at any point you looked down and realised what you were doing was
impossible then you'd instantly fail.
  -- Simon Wistow

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]