GNOME Bugzilla – Bug 321576
simple-browser.py show a critical warning (and doesn't work)
Last modified: 2006-10-09 13:21:45 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):
+ Trace 64082
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
I get a crash, not warnings: (gdb) bt full
+ Trace 64376
(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()
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
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?
I originally filled the bug into python binding, bug the findings of Gustavo, hi moved to gtkhtml2.
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... "
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.
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.
Steps to reproduce it: 1. Run it in a terminal: $ python ./simple-browser.py 2. Click over the link 'click me'.
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".
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.
*** Bug 360891 has been marked as a duplicate of this bug. ***