f



[wx 2.6.3, GTK+2 (Linux), gcc-3.2.2] wxTextCtrl causing segfault

Hello,
I am appending large amounts of text to a non-editable multiline  
wxTextCtrl, on wxGTK 2.6.3.  The text is broken up into 40K chunks,  
which are actually appended in 1K subchunks.  I am only able to  
append between 0 and 5 of these 40K chunks before I get a  
segmentation fault, with the following stack trace.  Although the  
segfault does not actually occur in the TextCtrl::Append call, it  
only happens when I am appending text, and my rather uninformed  
inspection of the stack trace indicates that something is going on in  
the gtk_text_view that underlies the wxTextCtrl.  My guess is that Im  
hitting some kind of maximum size limit for text controls, but I dont  
know much about GTK and couldnt find any documentation on about a  
maximum size.  Any advice/suggestions/help would be appreciated.

thanks
spencer

stack trace:

#0  0x40d649ae in g_slist_free () from /usr/lib/libglib-2.0.so.0
#1  0x40b0103a in gtk_text_layout_free_line_display ()
    from /usr/lib/libgtk-x11-2.0.so.0
#2  0x40b01c3e in gtk_text_layout_get_iter_location ()
    from /usr/lib/libgtk-x11-2.0.so.0
#3  0x40b0bfa3 in gtk_text_view_scroll_to_iter ()
    from /usr/lib/libgtk-x11-2.0.so.0
#4  0x40b0c511 in gtk_text_view_scroll_to_iter ()
    from /usr/lib/libgtk-x11-2.0.so.0
#5  0x40b0f22a in gtk_text_view_place_cursor_onscreen ()
    from /usr/lib/libgtk-x11-2.0.so.0
#6  0x40b10be2 in gtk_text_view_place_cursor_onscreen ()
    from /usr/lib/libgtk-x11-2.0.so.0
#7  0x40b10d0d in gtk_text_view_place_cursor_onscreen ()
    from /usr/lib/libgtk-x11-2.0.so.0
#8  0x40a77c2f in _gtk_marshal_BOOLEAN__BOXED ()
    from /usr/lib/libgtk-x11-2.0.so.0
#9  0x40cfb247 in g_cclosure_new_swap () from /usr/lib/ 
libgobject-2.0.so.0
#10 0x40cfaed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#11 0x40d0d439 in g_signal_emit_by_name () from /usr/lib/ 
libgobject-2.0.so.0
#12 0x40d0c7af in g_signal_emit_valist () from /usr/lib/ 
libgobject-2.0.so.0
#13 0x40d0cbe4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#14 0x40b5d6fb in gtk_widget_send_expose () from /usr/lib/libgtk- 
x11-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#15 0x40a766fc in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
#16 0x40c24db5 in gdk_window_clear_area_e () from /usr/lib/libgdk- 
x11-2.0.so.0
#17 0x40c24f88 in gdk_window_process_updates ()
    from /usr/lib/libgdk-x11-2.0.so.0
#18 0x40b14690 in gtk_text_view_get_default_attributes ()
    from /usr/lib/libgtk-x11-2.0.so.0
#19 0x40d0dd77 in g_cclosure_marshal_VOID__VOID ()
    from /usr/lib/libgobject-2.0.so.0
#20 0x40cfaed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#21 0x40d0d983 in g_signal_emit_by_name () from /usr/lib/ 
libgobject-2.0.so.0
#22 0x40d0c9a8 in g_signal_emit_valist () from /usr/lib/ 
libgobject-2.0.so.0
#23 0x40d0cbe4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#24 0x409e46eb in gtk_adjustment_value_changed ()
    from /usr/lib/libgtk-x11-2.0.so.0
#25 0x409e4573 in gtk_adjustment_set_value () from /usr/lib/libgtk- 
x11-2.0.so.0
#26 0x40b0be5e in gtk_text_view_get_line_at_y ()
    from /usr/lib/libgtk-x11-2.0.so.0
#27 0x40b0c16a in gtk_text_view_scroll_to_iter ()
    from /usr/lib/libgtk-x11-2.0.so.0
#28 0x40b0c511 in gtk_text_view_scroll_to_iter ()
    from /usr/lib/libgtk-x11-2.0.so.0
#29 0x40b0f22a in gtk_text_view_place_cursor_onscreen ()
    from /usr/lib/libgtk-x11-2.0.so.0
---Type <return> to continue, or q <return> to quit---
#30 0x40b0f2d7 in gtk_text_view_place_cursor_onscreen ()
    from /usr/lib/libgtk-x11-2.0.so.0
#31 0x40d55743 in g_timeout_add () from /usr/lib/libglib-2.0.so.0
#32 0x40d52b35 in g_get_current_time () from /usr/lib/libglib-2.0.so.0
#33 0x40d53b78 in g_main_context_dispatch () from /usr/lib/ 
libglib-2.0.so.0
#34 0x40d53e8d in g_main_context_dispatch () from /usr/lib/ 
libglib-2.0.so.0
#35 0x40d5458f in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
#36 0x40a75f5f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
#37 0x4016e7ba in wxEventLoop::Run() ()
    from /usr/local/lib/libwx_gtk2_core-2.6.so.0
#38 0x401f20ab in wxAppBase::MainLoop() ()
    from /usr/local/lib/libwx_gtk2_core-2.6.so.0
#39 0x401f21d3 in wxAppBase::OnRun() ()
    from /usr/local/lib/libwx_gtk2_core-2.6.so.0
#40 0x40409677 in wxEntry(int&, char**) ()
    from /usr/local/lib/libwx_base-2.6.so.0
#41 0x0805e994 in main ()
#42 0x4086fa67 in __libc_start_main () from /lib/i686/libc.so.6




---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
ssalazar
7/27/2006 9:25:24 PM
comp.soft-sys.wxwindows 21076 articles. 0 followers. Post Follow

2 Replies
650 Views

Similar Articles

[PageSpeed] 47

On Thu, 2006-07-27 at 17:25 -0400, Spencer Salazar wrote:
> Hello,
> I am appending large amounts of text to a non-editable multiline  
> wxTextCtrl, on wxGTK 2.6.3.  The text is broken up into 40K chunks,  
> which are actually appended in 1K subchunks.  I am only able to  
> append between 0 and 5 of these 40K chunks before I get a  
> segmentation fault, with the following stack trace.  Although the  
> segfault does not actually occur in the TextCtrl::Append call, it  
> only happens when I am appending text, and my rather uninformed  
> inspection of the stack trace indicates that something is going on in  
> the gtk_text_view that underlies the wxTextCtrl.  My guess is that Im  
> hitting some kind of maximum size limit for text controls, but I dont  
> know much about GTK and couldnt find any documentation on about a  
> maximum size.

The maximum size is something in gigabytes, so you are certainly not
hitting a maximum limit here.

> Any advice/suggestions/help would be appreciated.

As a general advice, you don't have to split it up to 1K subchunks
unless they have different styling. Another good thing might be to
Freeze and Thaw around the for loop if you have one (e.g, if you are
appending 40K in a for loop that appends 40 times in a row) - that will
at least speed things up, as it won't have to do the automatic scrolling
to the end, that I'm seeing in the scrollback.

But I don't know why it would crash, so the GTK+ version you are using
would be nice to know, and a minimal sample that reproduces the problem
would be also nice, even if using Freeze/Thaw happens to fix it :)

Thanks,
Mart Raudsepp

> thanks
> spencer
> 
> stack trace:
> 
> #0  0x40d649ae in g_slist_free () from /usr/lib/libglib-2.0.so.0
> #1  0x40b0103a in gtk_text_layout_free_line_display ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #2  0x40b01c3e in gtk_text_layout_get_iter_location ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #3  0x40b0bfa3 in gtk_text_view_scroll_to_iter ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #4  0x40b0c511 in gtk_text_view_scroll_to_iter ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #5  0x40b0f22a in gtk_text_view_place_cursor_onscreen ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #6  0x40b10be2 in gtk_text_view_place_cursor_onscreen ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #7  0x40b10d0d in gtk_text_view_place_cursor_onscreen ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #8  0x40a77c2f in _gtk_marshal_BOOLEAN__BOXED ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #9  0x40cfb247 in g_cclosure_new_swap () from /usr/lib/ 
> libgobject-2.0.so.0
> #10 0x40cfaed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #11 0x40d0d439 in g_signal_emit_by_name () from /usr/lib/ 
> libgobject-2.0.so.0
> #12 0x40d0c7af in g_signal_emit_valist () from /usr/lib/ 
> libgobject-2.0.so.0
> #13 0x40d0cbe4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
> #14 0x40b5d6fb in gtk_widget_send_expose () from /usr/lib/libgtk- 
> x11-2.0.so.0
> ---Type <return> to continue, or q <return> to quit---
> #15 0x40a766fc in gtk_main_do_event () from /usr/lib/libgtk-x11-2.0.so.0
> #16 0x40c24db5 in gdk_window_clear_area_e () from /usr/lib/libgdk- 
> x11-2.0.so.0
> #17 0x40c24f88 in gdk_window_process_updates ()
>     from /usr/lib/libgdk-x11-2.0.so.0
> #18 0x40b14690 in gtk_text_view_get_default_attributes ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #19 0x40d0dd77 in g_cclosure_marshal_VOID__VOID ()
>     from /usr/lib/libgobject-2.0.so.0
> #20 0x40cfaed7 in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
> #21 0x40d0d983 in g_signal_emit_by_name () from /usr/lib/ 
> libgobject-2.0.so.0
> #22 0x40d0c9a8 in g_signal_emit_valist () from /usr/lib/ 
> libgobject-2.0.so.0
> #23 0x40d0cbe4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
> #24 0x409e46eb in gtk_adjustment_value_changed ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #25 0x409e4573 in gtk_adjustment_set_value () from /usr/lib/libgtk- 
> x11-2.0.so.0
> #26 0x40b0be5e in gtk_text_view_get_line_at_y ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #27 0x40b0c16a in gtk_text_view_scroll_to_iter ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #28 0x40b0c511 in gtk_text_view_scroll_to_iter ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #29 0x40b0f22a in gtk_text_view_place_cursor_onscreen ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> ---Type <return> to continue, or q <return> to quit---
> #30 0x40b0f2d7 in gtk_text_view_place_cursor_onscreen ()
>     from /usr/lib/libgtk-x11-2.0.so.0
> #31 0x40d55743 in g_timeout_add () from /usr/lib/libglib-2.0.so.0
> #32 0x40d52b35 in g_get_current_time () from /usr/lib/libglib-2.0.so.0
> #33 0x40d53b78 in g_main_context_dispatch () from /usr/lib/ 
> libglib-2.0.so.0
> #34 0x40d53e8d in g_main_context_dispatch () from /usr/lib/ 
> libglib-2.0.so.0
> #35 0x40d5458f in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
> #36 0x40a75f5f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
> #37 0x4016e7ba in wxEventLoop::Run() ()
>     from /usr/local/lib/libwx_gtk2_core-2.6.so.0
> #38 0x401f20ab in wxAppBase::MainLoop() ()
>     from /usr/local/lib/libwx_gtk2_core-2.6.so.0
> #39 0x401f21d3 in wxAppBase::OnRun() ()
>     from /usr/local/lib/libwx_gtk2_core-2.6.so.0
> #40 0x40409677 in wxEntry(int&, char**) ()
>     from /usr/local/lib/libwx_base-2.6.so.0
> #41 0x0805e994 in main ()
> #42 0x4086fa67 in __libc_start_main () from /lib/i686/libc.so.6
> e_display ()
    from /usr/lib/libg
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
-- 
With regards,
Mart Raudsepp

Project manager of wxMUD
E-mail: leio@dustbite.net
http://wxmud.sourceforge.net/


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
leio
7/28/2006 9:43:25 AM
Thank you for your suggestions.

On Jul 28, 2006, at 5:43 AM, Mart Raudsepp wrote:

> The maximum size is something in gigabytes, so you are certainly not
> hitting a maximum limit here.

Good to know.

> Another good thing might be to
> Freeze and Thaw around the for loop if you have one (e.g, if you are
> appending 40K in a for loop that appends 40 times in a row) - that  
> will
> at least speed things up, as it won't have to do the automatic  
> scrolling
> to the end, that I'm seeing in the scrollback.

This seems to fix things up, for the most part, thank you.  However,  
when I call TextCtrl::SetInsertionPointEnd() right after the Thaw(),  
I get the same sort of erratic segfaulting behavior, with a similar  
stack trace.  It seems though that I dont need to call  
SetInsertionPointEnd() though because that is happening automatically  
for me already.

Additionally, the following prints periodically to stderr after a  
number of 40K chunks:
(miniAudicle:5731): Gtk-CRITICAL **: file gtktextlayout.c: line 2294  
(gtk_text_layout_get_iter_location): assertion  
'_gtk_text_iter_get_btree (iter) == _gtk_text_buffer_get_btree  
(layout->buffer)' failed

But all in all this seems to be stable enough for my application's  
needs.  The assertion failure has so far proved to be bothersome but  
not fatal.

> But I don't know why it would crash, so the GTK+ version you are using
> would be nice to know, and a minimal sample that reproduces the  
> problem
> would be also nice, even if using Freeze/Thaw happens to fix it :)

this is GTK+ 2.2.1...  perhaps upgrading would make a difference.

Ill try to reproduce this in a minimal example.

thanks!
spencer

>
> Thanks,
> Mart Raudsepp
>
>> thanks
>> spencer
>>
>> stack trace:
>>
>> #0  0x40d649ae in g_slist_free () from /usr/lib/libglib-2.0.so.0
>> #1  0x40b0103a in gtk_text_layout_free_line_display ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #2  0x40b01c3e in gtk_text_layout_get_iter_location ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #3  0x40b0bfa3 in gtk_text_view_scroll_to_iter ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #4  0x40b0c511 in gtk_text_view_scroll_to_iter ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #5  0x40b0f22a in gtk_text_view_place_cursor_onscreen ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #6  0x40b10be2 in gtk_text_view_place_cursor_onscreen ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #7  0x40b10d0d in gtk_text_view_place_cursor_onscreen ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #8  0x40a77c2f in _gtk_marshal_BOOLEAN__BOXED ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #9  0x40cfb247 in g_cclosure_new_swap () from /usr/lib/
>> libgobject-2.0.so.0
>> #10 0x40cfaed7 in g_closure_invoke () from /usr/lib/ 
>> libgobject-2.0.so.0
>> #11 0x40d0d439 in g_signal_emit_by_name () from /usr/lib/
>> libgobject-2.0.so.0
>> #12 0x40d0c7af in g_signal_emit_valist () from /usr/lib/
>> libgobject-2.0.so.0
>> #13 0x40d0cbe4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
>> #14 0x40b5d6fb in gtk_widget_send_expose () from /usr/lib/libgtk-
>> x11-2.0.so.0
>> ---Type <return> to continue, or q <return> to quit---
>> #15 0x40a766fc in gtk_main_do_event () from /usr/lib/libgtk- 
>> x11-2.0.so.0
>> #16 0x40c24db5 in gdk_window_clear_area_e () from /usr/lib/libgdk-
>> x11-2.0.so.0
>> #17 0x40c24f88 in gdk_window_process_updates ()
>>     from /usr/lib/libgdk-x11-2.0.so.0
>> #18 0x40b14690 in gtk_text_view_get_default_attributes ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #19 0x40d0dd77 in g_cclosure_marshal_VOID__VOID ()
>>     from /usr/lib/libgobject-2.0.so.0
>> #20 0x40cfaed7 in g_closure_invoke () from /usr/lib/ 
>> libgobject-2.0.so.0
>> #21 0x40d0d983 in g_signal_emit_by_name () from /usr/lib/
>> libgobject-2.0.so.0
>> #22 0x40d0c9a8 in g_signal_emit_valist () from /usr/lib/
>> libgobject-2.0.so.0
>> #23 0x40d0cbe4 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
>> #24 0x409e46eb in gtk_adjustment_value_changed ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #25 0x409e4573 in gtk_adjustment_set_value () from /usr/lib/libgtk-
>> x11-2.0.so.0
>> #26 0x40b0be5e in gtk_text_view_get_line_at_y ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #27 0x40b0c16a in gtk_text_view_scroll_to_iter ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #28 0x40b0c511 in gtk_text_view_scroll_to_iter ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #29 0x40b0f22a in gtk_text_view_place_cursor_onscreen ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> ---Type <return> to continue, or q <return> to quit---
>> #30 0x40b0f2d7 in gtk_text_view_place_cursor_onscreen ()
>>     from /usr/lib/libgtk-x11-2.0.so.0
>> #31 0x40d55743 in g_timeout_add () from /usr/lib/libglib-2.0.so.0
>> #32 0x40d52b35 in g_get_current_time () from /usr/lib/ 
>> libglib-2.0.so.0
>> #33 0x40d53b78 in g_main_context_dispatch () from /usr/lib/
>> libglib-2.0.so.0
>> #34 0x40d53e8d in g_main_context_dispatch () from /usr/lib/
>> libglib-2.0.so.0
>> #35 0x40d5458f in g_main_loop_run () from /usr/lib/libglib-2.0.so.0
>> #36 0x40a75f5f in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0
>> #37 0x4016e7ba in wxEventLoop::Run() ()
>>     from /usr/local/lib/libwx_gtk2_core-2.6.so.0
>> #38 0x401f20ab in wxAppBase::MainLoop() ()
>>     from /usr/local/lib/libwx_gtk2_core-2.6.so.0
>> #39 0x401f21d3 in wxAppBase::OnRun() ()
>>     from /usr/local/lib/libwx_gtk2_core-2.6.so.0
>> #40 0x40409677 in wxEntry(int&, char**) ()
>>     from /usr/local/lib/libwx_base-2.6.so.0
>> #41 0x0805e994 in main ()
>> #42 0x4086fa67 in __libc_start_main () from /lib/i686/libc.so.6
>> e_display ()
>     from /usr/lib/libg
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
>> For additional commands, e-mail: wx-users-help@lists.wxwidgets.org
> -- 
> With regards,
> Mart Raudsepp
>
> Project manager of wxMUD
> E-mail: leio@dustbite.net
> http://wxmud.sourceforge.net/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help@lists.wxwidgets.org


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wx-users-help@lists.wxwidgets.org

0
ssalazar
7/28/2006 5:12:10 PM
Reply: