[BUG] Segmentation fault if using PrintOperation for the sec


i attach a script, which sets page setup(this may not be necessary for
the bug to appear), and then enters a loop in which it calls
PrintOperation.run until it segfault.
the script generates a 61 page empty print context.

this is the output:
./printer3.rb:25: [BUG] Segmentation fault
ruby 1.8.5 (2006-08-25) [i686-linux]

this script is a simplified version of my print-testing script, in which
i noticed this error, i use cairo there, and thus get cairo error on
this same segfault:

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: line 27
Gtk-CRITICAL **:gtk_print_operation_preview_render_page: assertion
GTK_IS_PRINT_OPERATION_PREVIEW (preview)' failed ruby: cairo-surface.c:437: cairo_surface_destroy: Assertionsurface->ref_count > 0’ failed.


This seems a problem of GTK+, not Ruby/GTK.

I reported this to bugzilla.gnome.org.

The smallest sample to reproduce your problem is:

require ‘gtk2’

printo = Gtk::PrintOperation.new
printo.run(Gtk::PrintOperation::ACTION_PRINT_DIALOG, nil)
printo.run(Gtk::PrintOperation::ACTION_PRINT_DIALOG, nil)

And the equivalent source in C is:

#include <gtk/gtk.h>

int main(int argc, char** argv){
GtkPrintOperation* op;
GError* error = NULL;

gtk_init(&argc, &argv);

op = gtk_print_operation_new();
gtk_print_operation_set_n_pages(op, 1);
gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, &error);
gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, &error);
return 0;

You can compile this like as:
gcc -o test pkg-config gtk+-unix-print-2.0 --libs --cflags test.c

And it has same problem. The result of gdb is:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46912496299600 (LWP 13655)]
0x000000394bd5d5c5 in gtk_print_operation_preview_render_page ()
from /usr/lib64/libgtk-x11-2.0.so.0
(gdb) bt
#0 0x000000394bd5d5c5 in gtk_print_operation_preview_render_page ()
from /usr/lib64/libgtk-x11-2.0.so.0
#1 0x000000394bd5ce96 in gtk_print_operation_new ()
from /usr/lib64/libgtk-x11-2.0.so.0
#2 0x0000003f81a2cf44 in g_main_context_dispatch ()
from /lib64/libglib-2.0.so.0
#3 0x0000003f81a2fd7d in g_main_context_check () from
#4 0x0000003f81a3008a in g_main_loop_run () from
#5 0x000000394bd5acbe in gtk_print_context_get_cairo_context ()
from /usr/lib64/libgtk-x11-2.0.so.0
#6 0x000000394bd5b59f in gtk_print_operation_run ()
from /usr/lib64/libgtk-x11-2.0.so.0
#7 0x00000000004007b1 in main ()

On Sat, 25 Nov 2006 11:12:37 +0200
Dobai-Pataky Bálint [email protected] wrote:


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
opinions on IT & business topics through brief surveys - and earn cash