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 94658 - TextBuffer insert method using RefPtr<TextBuffer> yields core dump on G_IS_OBJECT assertion
TextBuffer insert method using RefPtr<TextBuffer> yields core dump on G_IS_OB...
Status: RESOLVED NOTABUG
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-10-02 06:31 UTC by fshim
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description fshim 2002-10-02 06:31:51 UTC
Word Description
----------------
    When I create a TextBuffer and perform some insertion of text into it,
I will eventually get a core dump due to an object integrity check by an
assertion.  Originally, I was using the TextBuffer in conjunction with a
TextView; however, I have narrowed down the sequence of operations that
seem to generate this problem.  In addition, the assertion appears to be at
the time of an "un-reference" by the RefPtr of the TextBuffer.
    To simplify the problem I wrote a *very* simple test program and
provide the following to assist debugging:

File: t.cc
------------------
#include        <gtkmm.h>

int     main (int argc, char** argv)
{
  Glib::RefPtr<Gtk::TextBuffer> rptxtbuf        = Gtk::TextBuffer::create ();

  rptxtbuf->insert_at_cursor ("This line is a test.\n");

  return 0;
}
-------------------
In Bash shell:

$ g++ t.cc -g `pkg-config gtkmm-2.0 --cflags --libs` -o t
$ ./t

(process:21719): GLib-GObject-CRITICAL **:
gtype.c:1806:g_type_register_static(): initialization assertion failed, use
g_type_init() prior to this function
Segmentation fault (core dumped)

$ gdb ./t core

GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 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-redhat-linux"...
Core was generated by `./t'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/g2dev/lib/libgtkmm-1.3.so.17...done.
Loaded symbols for /usr/g2dev/lib/libgtkmm-1.3.so.17
Reading symbols from /usr/g2dev/lib/libgdkmm-1.3.so.17...done.
Loaded symbols for /usr/g2dev/lib/libgdkmm-1.3.so.17
Reading symbols from /usr/g2dev/lib/libatkmm-0.0.so.17...done.
Loaded symbols for /usr/g2dev/lib/libatkmm-0.0.so.17
Reading symbols from /usr/g2dev/lib/libgtk-x11-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgtk-x11-2.0.so.0
Reading symbols from /usr/g2dev/lib/libpangomm-0.0.so.17...done.
Loaded symbols for /usr/g2dev/lib/libpangomm-0.0.so.17
Reading symbols from /usr/g2dev/lib/libglibmm-1.3.so.17...done.
Loaded symbols for /usr/g2dev/lib/libglibmm-1.3.so.17
Reading symbols from /usr/local/lib/libsigc-1.1.so.5...done.
Loaded symbols for /usr/local/lib/libsigc-1.1.so.5
Reading symbols from /usr/g2dev/lib/libgdk-x11-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgdk-x11-2.0.so.0
Reading symbols from /usr/local/lib/libatk-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libatk-1.0.so.0
Reading symbols from /usr/g2dev/lib/libgdk_pixbuf-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgdk_pixbuf-2.0.so.0
Reading symbols from /usr/local/lib/libpangoxft-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libpangoxft-1.0.so.0
Reading symbols from /usr/local/lib/libpangox-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libpangox-1.0.so.0
Reading symbols from /usr/local/lib/libpango-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libpango-1.0.so.0
Reading symbols from /usr/g2dev/lib/libgobject-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgobject-2.0.so.0
Reading symbols from /usr/g2dev/lib/libgmodule-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgmodule-2.0.so.0
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/g2dev/lib/libglib-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libglib-2.0.so.0
Reading symbols from /usr/lib/libstdc++-libc6.2-2.so.3...done.
Loaded symbols for /usr/lib/libstdc++-libc6.2-2.so.3
Reading symbols from /lib/i686/libm.so.6...done.
Loaded symbols for /lib/i686/libm.so.6
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /usr/X11R6/lib/libXft.so.1...done.
Loaded symbols for /usr/X11R6/lib/libXft.so.1
Reading symbols from /usr/X11R6/lib/libXrender.so.1...done.
Loaded symbols for /usr/X11R6/lib/libXrender.so.1
Reading symbols from /usr/X11R6/lib/libXext.so.6...done.
Loaded symbols for /usr/X11R6/lib/libXext.so.6
Reading symbols from /usr/X11R6/lib/libX11.so.6...done.
Loaded symbols for /usr/X11R6/lib/libX11.so.6
Reading symbols from /usr/lib/libfreetype.so.6...done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
  • #0 Glib::ustring::operator+=
    at /usr/include/g++-3/std/straits.h line 125
  • #0 Glib::ustring::operator+=
    at /usr/include/g++-3/std/straits.h line 125
  • #1 Glib::Class::register_derived_type
    at class.cc line 53
  • #2 Gtk::TextBuffer_Class::init
    at textbuffer.cc line 703
  • #3 Gtk::TextBuffer::TextBuffer
    at textbuffer.cc line 42
  • #4 Gtk::TextBuffer::create
    at ../../glib/glibmm/refptr.h line 173
  • #5 main
    at t.cc line 5
  • #6 __libc_start_main
    from /lib/i686/libc.so.6

----------------------------
(Although it may not be needed... Linux kernel is version 2.4.18-10, gcc is
version 2.96)

That is as much information I can give at the moment.  You should be able
to see the development environment (ie: versions of related packages) in
the gdb listing.  Hope this speel helps with the debugging.

Regards,
Frank
Comment 1 Murray Cumming 2002-10-02 09:56:35 UTC
This test code should not be expected to work, because you do not
initialize gtkmm or gtk - for example, you should use Gtk::Main, as we
do in the examples.

Also, try running your application with --g-fatal-warnings to debug
the cause of the warning.
Comment 2 fshim 2002-10-02 16:21:29 UTC
Understood.  The test program is an over-simplified version of the
more complex one that I have; however, I still get the same result
either way.  With that in mind, I pared the test program until I could
duplicate the problem consistently.
  In any case, I now provide the results of the modified test program
with only a Gtk::Main object added.  I also ran the test program with
the --g-fatal-warnings flag.  The stack trace still show the problem
in the "un-ref" of the TextBuffer RefPtr.
  Thanks, Murray, for taking a look... if I can be of further
assistance I will continue to work with you on this problem and
consider helping with sections that I can become familiar with for
future developments.

t.cc
--------------------
#include        <gtkmm.h>

int     main (int argc, char** argv)
{
  Gtk::Main     application (argc, argv);

  Glib::RefPtr<Gtk::TextBuffer> rptxtbuf = Gtk::TextBuffer::create();

  rptxtbuf->insert_at_cursor ("This line is a test.\n");

  return 0;
}
---------------------------
In Bash Shell:

$ g++ -g t.cc `pkg-config gtkmm-2.0 --cflags --libs` -o t
$ ./t --g-fatal-warnings

GLib-GObject-CRITICAL **: file gobject.c: line 1307 (g_object_unref):
assertion 
`G_IS_OBJECT (object)' failed
aborting...
Aborted (core dumped)

$ gdb ./t core

GNU gdb Red Hat Linux (5.2-2)
Copyright 2002 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-redhat-linux"...
Core was generated by `./t --g-fatal-warnings'.
Program terminated with signal 6, Aborted.
Reading symbols from /usr/g2dev/lib/libgtkmm-1.3.so.17...done.
Loaded symbols for /usr/g2dev/lib/libgtkmm-1.3.so.17
Reading symbols from /usr/g2dev/lib/libgdkmm-1.3.so.17...done.
Loaded symbols for /usr/g2dev/lib/libgdkmm-1.3.so.17
Reading symbols from /usr/g2dev/lib/libatkmm-0.0.so.17...done.
Loaded symbols for /usr/g2dev/lib/libatkmm-0.0.so.17
Reading symbols from /usr/g2dev/lib/libgtk-x11-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgtk-x11-2.0.so.0
Reading symbols from /usr/g2dev/lib/libpangomm-0.0.so.17...done.
Loaded symbols for /usr/g2dev/lib/libpangomm-0.0.so.17
Reading symbols from /usr/g2dev/lib/libglibmm-1.3.so.17...done.
Loaded symbols for /usr/g2dev/lib/libglibmm-1.3.so.17
Reading symbols from /usr/local/lib/libsigc-1.1.so.5...done.
Loaded symbols for /usr/local/lib/libsigc-1.1.so.5
Reading symbols from /usr/g2dev/lib/libgdk-x11-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgdk-x11-2.0.so.0
Reading symbols from /usr/local/lib/libatk-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libatk-1.0.so.0
Reading symbols from /usr/g2dev/lib/libgdk_pixbuf-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgdk_pixbuf-2.0.so.0
Reading symbols from /usr/local/lib/libpangoxft-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libpangoxft-1.0.so.0
Reading symbols from /usr/local/lib/libpangox-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libpangox-1.0.so.0
Reading symbols from /usr/local/lib/libpango-1.0.so.0...done.
Loaded symbols for /usr/local/lib/libpango-1.0.so.0
Reading symbols from /usr/g2dev/lib/libgobject-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgobject-2.0.so.0
Reading symbols from /usr/g2dev/lib/libgmodule-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libgmodule-2.0.so.0
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /usr/g2dev/lib/libglib-2.0.so.0...done.
Loaded symbols for /usr/g2dev/lib/libglib-2.0.so.0
Reading symbols from /usr/lib/libstdc++-libc6.2-2.so.3...done.
Loaded symbols for /usr/lib/libstdc++-libc6.2-2.so.3
Reading symbols from /lib/i686/libm.so.6...done.
Loaded symbols for /lib/i686/libm.so.6
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /usr/X11R6/lib/libXft.so.1...done.
Loaded symbols for /usr/X11R6/lib/libXft.so.1
Reading symbols from /usr/X11R6/lib/libXrender.so.1...done.
Loaded symbols for /usr/X11R6/lib/libXrender.so.1
Reading symbols from /usr/X11R6/lib/libXext.so.6...done.
Loaded symbols for /usr/X11R6/lib/libXext.so.6
Reading symbols from /usr/X11R6/lib/libX11.so.6...done.
Loaded symbols for /usr/X11R6/lib/libX11.so.6
Reading symbols from /usr/lib/libfreetype.so.6...done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/X11R6/lib/X11/locale/common/xlcDef.so.2...done.
Loaded symbols for /usr/X11R6/lib/X11/locale/common/xlcDef.so.2
Reading symbols from /lib/libnss_files.so.2...done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /usr/lib/gconv/ISO8859-1.so...done.
Loaded symbols for /usr/lib/gconv/ISO8859-1.so
  • #0 kill
    from /lib/i686/libc.so.6
  • #0 kill
    from /lib/i686/libc.so.6
  • #1 raise
    from /lib/i686/libc.so.6
  • #2 abort
    from /lib/i686/libc.so.6
  • #3 g_logv
  • #4 g_log
  • #5 g_object_unref
    at gobject.c line 1308
  • #6 _gtk_text_btree_unref
    at gtktextbtree.c line 520
  • #7 gtk_text_buffer_finalize
    at gtktextbuffer.c line 356
  • #8 g_object_last_unref
    at gobject.c line 434
  • #9 g_object_unref
    at gobject.c line 1318
  • #10 Glib::ObjectBase::unreference
    at objectbase.cc line 106
  • #11 Glib::RefPtr<Gtk::TextBuffer>::~RefPtr
    at /usr/g2dev/include/gtkmm-2.0/glibmm/refptr.h line 168
  • #12 main
    at t.cc line 11
  • #13 __libc_start_main
    from /lib/i686/libc.so.6

Regards,
Frank Shim

Comment 3 Murray Cumming 2002-10-02 17:21:22 UTC
Could you try it with plain GTK+ C code, to see if it's a problem in
gtkmm?
Comment 4 fshim 2002-10-03 06:06:54 UTC
Okay...

Here is my attempt at duplicating the test program in GTK+ 2.0.

t.c
-----------------------
#include        <gtk/gtk.h>
#include        <gtk/gtktextbuffer.h>
#include        <gtk/gtktextiter.h>

int     main (int argc, char** argv)
{
  GtkTextBuffer*        txtbuf;

  gtk_init (&argc, &argv);

  txtbuf        = gtk_text_buffer_new (NULL);

  gtk_text_buffer_insert_at_cursor (txtbuf, "This line is a test\n", 20);

  return 0;
}
--------------------------
In Bash Shell

$ gcc -g t.c `pkg-config gtk+-2.0 --cflags --libs` -o tt
$ ./tt
$ ./tt --g-fatal-warnings
$
--------------------------
No core dumps; however, it may be due to the fact that I will have to
do the equivalent of 'C++ destructor like' calls in GTK+ 2.0.  My
thinking is that it has more to do with the RefPtr<> implementation of
TextBuffer class referencing/deferencing.

Let me know what you think.

Regards,
Frank Shim
Comment 5 Murray Cumming 2002-10-12 13:50:14 UTC
I tried the C++ test code without problems. I seem to remember that we
fixed something like this recently so maybe you should try a newer
version. Please reopen the bug if it's still a problem.