After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 704143 - Crash when using both object-oriented and Exporter-based modules in a Gtk3-Perl program
Crash when using both object-oriented and Exporter-based modules in a Gtk3-Pe...
Status: RESOLVED FIXED
Product: gnome-perl
Classification: Bindings
Component: Gtk3
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2013-07-13 08:46 UTC by Kari Hänninen
Modified: 2013-09-24 17:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid memory corruption when registering boxed synonyms repeatedly (753 bytes, patch)
2013-07-14 20:42 UTC, Torsten Schoenfeld
committed Details | Review

Description Kari Hänninen 2013-07-13 08:46:51 UTC
The example code below makes perl 5.16 dump core, and 5.18 die with this error:
Can't call method "export" on an undefined value at /usr/lib/perl5/current/Exporter/Heavy.pm line 214.
BEGIN failed--compilation aborted at Utils.pm line 4.
Compilation failed in require at MainWindow.pm line 6.
BEGIN failed--compilation aborted at MainWindow.pm line 6.
Compilation failed in require at ./example.pl line 5.
BEGIN failed--compilation aborted at ./example.pl line 5.

If I use only object-oriented or only Exporter-based modules, then it works and does not crash. Mixing both types triggers the bug. Gtk2 version of the programs also works correctly in any case.

example.pl:
#!/usr/bin/perl -w

use strict;
use Gtk3 '-init';
use MainWindow;

my $window = MainWindow->new();
$window->show_all();
Gtk3->main();

MainWindow.pm:
package MainWindow;

use strict;
use Gtk3;
use parent -norequire, 'Gtk3::Window';
use Utils;


sub new
{
  my($class) = @_;
  my $self = bless Gtk3::Window->new('toplevel'), $class;
  $self->add(entry_with_clear_button());
  $self->set_title('Gtk3-Perl Bug Example');
  $self->signal_connect(delete_event => sub { Gtk3->main_quit(); });
  return $self;
}

1;

Utils.pm:
package Utils;

use strict;
use Gtk3;
use Exporter;
use vars qw(@ISA @EXPORT);

@ISA = qw(Exporter);
@EXPORT = qw(entry_with_clear_button);

sub entry_with_clear_button
{
  my $entry = Gtk3::Entry->new();
  $entry->set_icon_from_stock('secondary', 'gtk-clear');
  $entry->set_icon_activatable('secondary', 1);
  $entry->signal_connect(icon_release => \&clear_entry);
  return $entry;
}

sub clear_entry
{
  my($self, $pos, $event) = @_;
  if($pos eq 'secondary')
  {
    $self->set_text('');
  }
}

1;
Comment 1 Torsten Schoenfeld 2013-07-14 20:42:28 UTC
Created attachment 249139 [details] [review]
Avoid memory corruption when registering boxed synonyms repeatedly
Comment 2 Torsten Schoenfeld 2013-07-14 20:44:04 UTC
This appears to be due to a memory-corrupting bug in Glib.  It doesn't seem to be related to Exporter; all you need is three imports of Gtk3:

#!/usr/bin/perl
package Bla;
use Gtk3;
package BlaBla;
use Gtk3;
package main;
use Gtk3;

The above patch should fix the issue; please try it.
Comment 3 Kari Hänninen 2013-07-15 04:16:29 UTC
The patch appears to work. Thank you!
Comment 4 Torsten Schoenfeld 2013-09-24 17:41:45 UTC
Attachment 249139 [details] pushed as cda1f5a - Avoid memory corruption when registering boxed synonyms repeatedly