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 321576 - simple-browser.py show a critical warning (and doesn't work)
simple-browser.py show a critical warning (and doesn't work)
Status: RESOLVED FIXED
Product: gnome-python-extras
Classification: Deprecated
Component: gtkhtml2
CVS HEAD
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
: 360891 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2005-11-16 02:43 UTC by Germán Poo-Caamaño
Modified: 2006-10-09 13:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Python script test-case (1.60 KB, text/plain)
2006-08-19 04:21 UTC, Germán Poo-Caamaño
Details

Description Germán Poo-Caamaño 2005-11-16 02:43:30 UTC
Distribution/Version: Ubuntu Breezy

Run python simple-browser.py, click over the link.  Dissapear the link, but not
the text.  Nothing else happen, except the following error in the terminal:

gpoo@mimos:/usr/share/doc/python2.4-gnome2-extras/examples/gtkhtml2$ python
simple-browser.py
link_clicked: http://www.gnome.org/
simple-browser.py:45: Warning: invalid unclassed pointer in cast to `GObject'
  document.close_stream()
simple-browser.py:45: Warning: g_object_unref: assertion `G_IS_OBJECT (object)'
failed
  document.close_stream()

** (simple-browser.py:8618): CRITICAL **: dom_Document__get_documentElement:
assertion `doc != NULL' failed
Traceback (most recent call last):
  • File "simple-browser.py", line 72 in ?
    gtk.main() KeyboardInterrupt

I'm using Ubuntu Breezy. Relevants packages:

ii  python2.4-glade2   2.8.1-0ubuntu2     GTK+ bindings: Glade support
ii  python2.4-gnome2   2.12.1-0ubuntu1    Python bindings for the GNOME desktop
environment
ii  python2.4-gnome2-e 2.12.0-0ubuntu1    Python bindings for the GNOME desktop
environment
ii  python2.4-gtk2     2.8.1-0ubuntu2     Python bindings for the GTK+ widget set
ii  libgtkhtml2-0      2.6.3-1            HTML rendering/editing library -
runtime files. (for
Comment 1 Gustavo Carneiro 2005-12-01 17:39:38 UTC
I get a crash, not warnings:

(gdb) bt full
  • #0 ??
  • #1 html_stream_write
    at htmlstream.c line 85
  • #2 html_document_write_stream
    at htmldocument.c line 777
  • #3 _wrap_html_document_write_stream
    at gtkhtml2.override line 34
  • #4 PyCFunction_Call
  • #1 html_stream_write
    at htmlstream.c line 85

(gdb) p *stream
$1 = {parent_object = {g_type_instance = {g_class = 0x0},
    ref_count = 2863311530, qdata = 0xaaaaaaaa}, write_func = 0xaaaaaaaa,
  close_func = 0xaaaaaaaa, cancel_func = 0xaaaaaaaa, user_data = 0xaaaaaaaa,
  cancel_data = 0xaaaaaaaa, written = -1431655766,
  mime_type = 0xaaaaaaaa <Address 0xaaaaaaaa out of bounds>}

So the document->current_stream object is dead but gtkhtml2 doesn't know it. 
This is not a wrapper bug...

Python code that triggers the crash:
[...]
    document.clear()
    headers = f.info()
    mime = headers.getheader('Content-type')
    if mime:
        document.open_stream(mime)
    else:
        document.open_stream('text/plain')
    document.write_stream(f.read()) # <--- crashes here
    document.close_stream()
Comment 2 Germán Poo-Caamaño 2006-01-11 03:05:08 UTC
Just for the record,

I just tested it in a Debian machine, with the previous bindings and it works ok, even with the new libgtkhtml2.

ii  libgtkhtml2-0       2.6.3-1
ii  python-gtk2         2.6.3-2
ii  python2.3-gtk2      2.6.3-2
Comment 3 Rodney Dawes 2006-08-18 20:48:33 UTC
This sounds like a bindings bug, not a gtkhtml2 bug to me. Can someone confirm this and move to the proper product/component for the python bindings if so?
Comment 4 Germán Poo-Caamaño 2006-08-18 21:18:48 UTC
I originally filled the bug into python binding, bug the findings of Gustavo, hi moved to gtkhtml2.
Comment 5 Germán Poo-Caamaño 2006-08-18 21:20:35 UTC
I forgot to remark the Gustavo's comment:

"...
(gdb) p *stream
$1 = {parent_object = {g_type_instance = {g_class = 0x0},
    ref_count = 2863311530, qdata = 0xaaaaaaaa}, write_func = 0xaaaaaaaa,
  close_func = 0xaaaaaaaa, cancel_func = 0xaaaaaaaa, user_data = 0xaaaaaaaa,
  cancel_data = 0xaaaaaaaa, written = -1431655766,
  mime_type = 0xaaaaaaaa <Address 0xaaaaaaaa out of bounds>}

So the document->current_stream object is dead but gtkhtml2 doesn't know it. 
This is not a wrapper bug...
"
Comment 6 Rodney Dawes 2006-08-19 03:21:31 UTC
Can you attach a script or equivalent C code that reproduces this problem then? What is simple-browser.py? It's not obvious to me how to reproduce the problem, looking at the backtrace.
Comment 7 Germán Poo-Caamaño 2006-08-19 04:21:22 UTC
Created attachment 71196 [details]
Python script test-case

This is the python script bundled as example of gnome-python-extras.  It also locate at http://cvs.gnome.org/viewcvs/gnome-python-extras/examples/gtkhtml2/

The script used to work and the last time it was modified was 4 years ago.
Comment 8 Germán Poo-Caamaño 2006-08-19 04:24:52 UTC
Steps to reproduce it:

1. Run it in a terminal:
   $ python ./simple-browser.py
2. Click over the link 'click me'.
Comment 9 Rodney Dawes 2006-08-19 14:02:39 UTC
OK. The problem is that the bindings are reporting that the html_document_open_stream call has no return value, when the C API returns a boolean. I don't see how this ever worked, unless www.gnome.org was returning only "Content-type: text/html" in the headers before. The "; charset=utf-8" is causing html_document_open_stream () to fail, when you pass in the content-type header value directly without parsing it, and then you try to write/close on a stream that doesn't exist. The only thing that changed in the last 5 years in the html_document_open_stream method, is that padraig added an html_document_clear call to the method, so that it automatically clears it.

This is definitely an issue with the bindings and simple-browser.py code, as it isn't doing any proper error checking, and ignores a boolean return value. And for what it's worth, the API only handles "text/html" as a valid mime type, so even in the fallback case in simple-browser.py, it would still fail, as it returns FALSE if the type is not "text/html".
Comment 10 Gustavo Carneiro 2006-08-19 16:43:52 UTC
Thanks, indeed it was a bug in the example program.
I also made the bindings raise an exception when html_document_open_stream returns FALSE.

Fixed in CVS. The fix will go into the next patch release. Thank you for your bug report.
Comment 11 Gustavo Carneiro 2006-10-09 13:21:45 UTC
*** Bug 360891 has been marked as a duplicate of this bug. ***