Re: Crashes with long words in strings passed to gtk_widget_set_tooltip_text()



It seems gdk pixmap width is stored as 16-bit unsigned int and x pixmap
width as 16-bit signed int. Usually, tooltip texts are rather short and
your app don't need to check anything. And I can't see why somebody
would need a windows wider than 32 K, unless an unrealized one for some
special purposes. If you really want to safely pass a very long text,
you will have to know the font (family and size) then check with stuff
like pango_layout_set_text() and pango_layout_get_pixel_size().


On 04/19/2011 07:17 PM, Emmanuel Thomas-Maurin wrote:
> The text is too long. Rendering it creates a Gdk pixmap that is *too
> wide* (width > 64 k - 1, not supported.)
> 
> AFAIY, X pixmaps can't be wider than 32 K - 1 but I may be wrong. This
> could relate to X, not GTK itself.
> 
> 
> On 04/19/2011 05:50 PM, Fabian Keil wrote:
>> The attached example program (by Colin Leroy) passes a string
>> with a long "word" to gtk_widget_set_tooltip_text() which causes
>> a crash when the tooltip is supposed to be shown.
>>
>> (gdb) r --sync
>> Starting program: /home/fk/kram/tooltip-crashes/long_tooltip_crash --sync
>> [New LWP 101212]
>> [New Thread 805407400 (LWP 101212/initial thread)]
>>
>> (long_tooltip_crash:65109): Gdk-WARNING **: Native Windows wider or taller than 65535 pixels are not supported
>>
>> Gdk-ERROR **: The program 'long_tooltip_crash' received an X Window System error.
>> This probably reflects a bug in the program.
>> The error was 'BadAlloc (insufficient resources for operation)'.
>>   (Details: serial 725 error_code 11 request_code 53 minor_code 0)
>>   (Note to programmers: normally, X errors are reported asynchronously;
>>    that is, you will receive the error a while after causing it.
>>    To debug your program, run it with the --sync command line
>>    option to change this behavior. You can then get a meaningful
>>    backtrace from your debugger if you break on the gdk_x_error() function.)
>> aborting...
>>
>> Program received signal SIGABRT, Aborted.
>> [Switching to Thread 805407400 (LWP 101212/initial thread)]
>> 0x0000000803e77d5c in thr_kill () from /lib/libc.so.7
>> (gdb) where
>> #0  0x0000000803e77d5c in thr_kill () from /lib/libc.so.7
>> #1  0x0000000803f16b73 in abort () from /lib/libc.so.7
>> #2  0x0000000803a4fc1a in g_logv (log_domain=0x801059b3a "Gdk", log_level=G_LOG_LEVEL_ERROR, format=0x801059dbe "%s", args1=0x7fffffffc2f0) at gmessages.c:557
>> #3  0x0000000803a4fdbb in g_log (log_domain=0x801059b3a "Gdk", log_level=G_LOG_LEVEL_ERROR, format=0x801059dbe "%s") at gmessages.c:577
>> #4  0x0000000801019b1f in gdk_x_error (display=0x805504800, error=0x7fffffffc4a0) at gdkmain-x11.c:466
>> #5  0x00000008029d1054 in _XError (dpy=0x805504800, rep=0x80569f8e0) at XlibInt.c:3105
>> #6  0x00000008029d9f40 in handle_error (dpy=0x805504800, err=0x80569f8e0, in_XReply=1) at xcb_io.c:166
>> #7  0x00000008029da30d in handle_response (dpy=0x805504800, response=0x80569f8e0, in_XReply=1) at xcb_io.c:265
>> #8  0x00000008029dae39 in _XReply (dpy=0x805504800, rep=0x7fffffffc6b0, extra=0, discard=1) at xcb_io.c:554
>> #9  0x00000008029c8b70 in XSync (dpy=0x805504800, discard=0) at Sync.c:46
>> #10 0x00000008029c8c5e in _XSyncFunction (dpy=0x18b5c) at Synchro.c:35
>> #11 0x00000008029ce5e6 in _XPrivSyncFunction (dpy=0x805504800) at XlibInt.c:603
>> #12 0x000000080299a983 in XCreatePixmap (dpy=0x805504800, d=48234537, width=65535, height=23, depth=24) at CrPixmap.c:58
>> #13 0x000000080101a940 in _gdk_pixmap_new (drawable=0x8054c6480, width=65535, height=23, depth=24) at gdkpixmap-x11.c:175
>> #14 0x0000000800fcaa95 in IA__gdk_pixmap_new (drawable=0x8054c6480, width=65535, height=23, depth=-1) at gdkpixmap.c:249
>> #15 0x0000000800fdd59a in gdk_window_begin_implicit_paint (window=0x8054c6480, rect=0x7fffffffc8e0) at gdkwindow.c:2773
>> #16 0x0000000800fe2caa in gdk_window_process_updates_internal (window=0x8054c6480) at gdkwindow.c:5569
>> #17 0x0000000800fe30aa in IA__gdk_window_process_updates (window=0x8054c6480, update_children=1) at gdkwindow.c:5757
>> #18 0x0000000800b934f8 in gtk_window_move_resize (window=0x8054c8280) at gtkwindow.c:6246
>> #19 0x0000000800b92172 in gtk_window_check_resize (container=0x8054c8280) at gtkwindow.c:5408
>> #20 0x00000008036c21a9 in g_cclosure_marshal_VOID__VOID (closure=0x8056de5a0, return_value=0x0, n_param_values=1, param_values=0x80544aa00, invocation_hint=0x7fffffffceb0, 
>>     marshal_data=0x800b92130) at gmarshal.c:79
>> #21 0x00000008036a6ab2 in g_type_class_meta_marshal (closure=0x8056de5a0, return_value=0x0, n_param_values=1, param_values=0x80544aa00, invocation_hint=0x7fffffffceb0, marshal_data=0x2e0)
>>     at gclosure.c:877
>> #22 0x00000008036a6766 in g_closure_invoke (closure=0x8056de5a0, return_value=0x0, n_param_values=1, param_values=0x80544aa00, invocation_hint=0x7fffffffceb0) at gclosure.c:766
>> #23 0x00000008036c17a6 in signal_emit_unlocked_R (node=0x805478f60, detail=0, instance=0x8054c8280, emission_return=0x0, instance_and_params=0x80544aa00) at gsignal.c:3290
>> #24 0x00000008036c02b2 in g_signal_emit_valist (instance=0x8054c8280, signal_id=82, detail=0, var_args=0x7fffffffd230) at gsignal.c:2983
>> #25 0x00000008036c0899 in g_signal_emit (instance=0x8054c8280, signal_id=82, detail=0) at gsignal.c:3040
>> #26 0x00000008009350ae in IA__gtk_container_check_resize (container=0x8054c8280) at gtkcontainer.c:1431
>> #27 0x0000000800934d74 in gtk_container_idle_sizer (data=0x0) at gtkcontainer.c:1356
>> #28 0x0000000800fb2d58 in gdk_threads_dispatch (data=0x80544ac20) at gdk.c:512
>> #29 0x0000000803a4834b in g_idle_dispatch (source=0x805699ac0, callback=0x800fb2d00 <gdk_threads_dispatch>, user_data=0x80544ac20) at gmain.c:4254
>> #30 0x0000000803a43d9d in g_main_dispatch (context=0x80547a500) at gmain.c:2149
>> #31 0x0000000803a455d5 in g_main_context_dispatch (context=0x80547a500) at gmain.c:2702
>> #32 0x0000000803a45ba6 in g_main_context_iterate (context=0x80547a500, block=1, dispatch=1, self=0x805417500) at gmain.c:2780
>> #33 0x0000000803a46443 in g_main_loop_run (loop=0x8056a31a0) at gmain.c:2988
>> #34 0x00000008009e516c in IA__gtk_main () at gtkmain.c:1237
>> #35 0x0000000000400ee5 in main ()
>>
>> I'm using GTK+ 2.22.1.
>>
>> From the documentation at:
>> http://developer.gimp.org/api/2.0/gtk/GtkWidget.html#gtk-widget-set-tooltip-text
>> the expected behaviour isn't clear to me.
>>
>> Is the crash a bug, or are applications supposed to somehow
>> verify that the tooltip text can't reach the limit mentioned
>> in the warning (or any other limits)?
>>
>> Thanks
>> Fabian
>>
>>
>>
>> _______________________________________________
>> gtk-devel-list mailing list
>> gtk-devel-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gtk-devel-list
> 
> 


-- 
Emmanuel Thomas-Maurin <manutm007 gmail com>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]