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 507610 - gtk2-perl unthreads safe
gtk2-perl unthreads safe
Status: RESOLVED NOTABUG
Product: gnome-perl
Classification: Bindings
Component: Gtk2::GladeXML
unspecified
Other All
: Normal critical
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2008-01-06 04:55 UTC by yarp
Modified: 2008-01-06 06:30 UTC
See Also:
GNOME target: ---
GNOME version: 2.7/2.8



Description yarp 2008-01-06 04:55:00 UTC
Steps to reproduce:
1. In linux(Debian AMD64)log error messages when call $thread->join.
2. In windowsXP log error messages and crash when call $thread->join.
3. No mater use or not use gtk_idle_add, and if have "use Gtk2 -init -threads-init;" widgets didn't display correctly.


Stack trace:


Other information:
glade file(threads.glade):
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkWindow" id="window1">
  <property name="visible">True</property>
  <property name="title" translatable="yes">window1</property>
  <property name="type">GTK_WINDOW_TOPLEVEL</property>
  <property name="window_position">GTK_WIN_POS_NONE</property>
  <property name="modal">False</property>
  <property name="resizable">True</property>
  <property name="destroy_with_parent">False</property>
  <property name="decorated">True</property>
  <property name="skip_taskbar_hint">False</property>
  <property name="skip_pager_hint">False</property>
  <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>

  <child>
    <widget class="GtkButton" id="button1">
      <property name="visible">True</property>
      <property name="can_focus">True</property>
      <property name="label" translatable="yes">button1</property>
      <property name="use_underline">True</property>
      <property name="relief">GTK_RELIEF_NORMAL</property>
      <property name="focus_on_click">True</property>
      <signal name="clicked" handler="on_button1_clicked" last_modification_time="Sat, 05 Jan 2008 15:07:29 GMT"/>
    </widget>
  </child>
</widget>

</glade-interface>

perl script:

  use FindBin qw($Bin);
  use strict;
  use Gtk2 qw( -init -threads-init);
  use threads;
  use Glib;
  use Gtk2::GladeXML;
  my $flag;
  our $gladexml = Gtk2::GladeXML->new("$Bin/threads.glade"); 
  $gladexml->signal_autoconnect_from_package('main');
#  Glib::Idle->add(sub {on_button1_clicked()});
  Gtk2->main;
  sub gtk_main_quit()
  	{Gtk2->main_quit;}
  sub on_button1_clicked{
	  my $thread = threads->create(sub {print "Thread created\n"});
	  $thread->join;
  }
symptom:
click button1 three times log such messages or crash in windows.
Thread created
Thread created
Thread created
GLib-GObject-CRITICAL **: g_object_steal_qdata: assertion `G_IS_OBJECT (object)' failed during global destruction.
GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed during global destruction.
Thread created
GLib-GObject-CRITICAL **: g_object_steal_qdata: assertion `G_IS_OBJECT (object)' failed during global destruction.
GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed during global destruction.
Thread created
GLib-GObject-CRITICAL **: g_object_steal_qdata: assertion `G_IS_OBJECT (object)' failed during global destruction.
GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed during global destruction.
Thread created
GLib-GObject-CRITICAL **: g_object_steal_qdata: assertion `G_IS_OBJECT (object)' failed during global destruction.
GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed during global destruction.
......
Comment 1 muppet 2008-01-06 06:30:38 UTC
If you add the line

  die "Failed to enable thread safety"
      unless Glib::Object->set_threadsafe (1);

immediately after the "use Glib;" line (specifically, before any calls to Glib or Gtk2 or related packages), then your example script no longer crashes.  Instead, i see a "Scalars leaked: 1" message at the close of each thread, which is, i believe, related to the fact that the object is being kept alive by the object tracking.

Please see:

"Can I use threads with gtk2-perl" entry in FAQ  (predates object tracking)
http://live.gnome.org/GTK2-Perl/FrequentlyAskedQuestions#head-4d5ea9310685f66fc167cf8497357e341f73128b

Glib::Object::set_threadsafe()
http://gtk2-perl.sourceforge.net/doc/pod/Glib/Object.html#boolean_Glib_Object_

"gtk2-perl thread safe" mailing list announcement
http://mail.gnome.org/archives/gtk-perl-list/2004-May/msg00094.html

zentara has a decent summary of how to do thread-safety here:
http://objectmix.com/perl/19619-perl-s-gui-2.html#post63228


If that doesn't fix your problem, please reopen.