wxGTK Crash programmatically modifying wxTextCtrl from wxEVT_TEXT (Issue #26742)

19 views
Skip to first unread message

Ryan Ogurek

unread,
Jul 26, 2026, 4:28:29 PM (9 days ago) Jul 26
to wx-...@googlegroups.com, Subscribed
ryancog created an issue (wxWidgets/wxWidgets#26742)

Description

Whenever a user enters text into a textbox, I use the wxEVT_TEXT to process it, and potentially change the field. Probably I should be using validators for this, but in any case...

Bug description:

This works fine whenever a user enters text usually (on macOS, Windows, and Linux), but specifically with wxGTK whenever a user pastes text and the program modifies it, from the EVT_TEXT, wxWidgets crashes.

It crashes in my program in au_insert_text_callback, but with the text sample patch I provide, it seems to be crashing in au_delete_range_callback.

In the text sample, there are warnings in the output about an invalid text buffer iterator.

Expected vs observed behaviour:

I'd expect that modifying text in wxEVT_TEXT works fine when pasting, as it does on other platforms and when the user enters text via typing.

Stack trace:

#0  0x00007ffff64d9f7b in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#1  0x00007ffff64dbdc7 in gtk_text_iter_forward_line () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#2  0x00007ffff64dc229 in gtk_text_iter_forward_to_line_end () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#3  0x00007ffff784397b in au_delete_range_callback (win=<optimized out>, start=0x7fffffffd610, end=0x7fffffffd570) at ../src/gtk/textctrl.cpp:619
#4  au_delete_range_callback (start=0x7fffffffd610, end=0x7fffffffd570, win=<optimized out>) at ../src/gtk/textctrl.cpp:608
#5  0x00007ffff6ea4950 in g_closure_invoke () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff6eb909d in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff6eba769 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff6ec05a6 in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff6ec0663 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#10 0x00007ffff64cdc08 in gtk_text_buffer_delete_interactive () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#11 0x00007ffff64cdd7b in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#12 0x00007ffff64cdeb8 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#13 0x00007ffff6599d74 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#14 0x00007ffff6598f97 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#15 0x00007ffff629ce12 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#16 0x00007ffff6ea4b81 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#17 0x00007ffff6eba8b8 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#18 0x00007ffff6ec086e in g_signal_emit_by_name () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#19 0x00007ffff64964e6 in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#20 0x00007ffff6297d7a in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#21 0x00007ffff6ea4b81 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#22 0x00007ffff6eb9b33 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#23 0x00007ffff6ec05a6 in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#24 0x00007ffff6ec0663 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#25 0x00007ffff65558fc in ??? () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#26 0x00007ffff640802a in gtk_main_do_event () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#27 0x00007ffff6f305c9 in ??? () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#28 0x00007ffff6f64c96 in ??? () at /lib/x86_64-linux-gnu/libgdk-3.so.0
#29 0x00007ffff5dbe385 in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#30 0x00007ffff5dc05b7 in ??? () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#31 0x00007ffff5dc101f in g_main_loop_run () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#32 0x00007ffff640705d in gtk_main () at /lib/x86_64-linux-gnu/libgtk-3.so.0
#33 0x00007ffff7785455 in wxGUIEventLoop::DoRun (this=0x555555a00590) at ../src/gtk/evtloop.cpp:68
#34 0x00007ffff70fc8fa in wxEventLoopBase::Run (this=0x555555a00590) at ../src/common/evtloopcmn.cpp:88
#35 0x00007ffff70a9f6b in wxAppConsoleBase::MainLoop (this=0x5555555fdcf0) at ../src/common/appbase.cpp:393
#36 0x00007ffff715dd59 in operator() (__closure=<optimized out>) at ../src/common/init.cpp:563
#37 wxSafeCall<int, wxEntry(int&, wxChar**)::<lambda()>, wxEntry(int&, wxChar**)::<lambda()> > (func=<optimized out>) at ../include/wx/private/safecall.h:62
#38 wxEntry (argc=@0x7ffff73aa9a0: 1, argv=0x5555555fc0b0) at ../src/common/init.cpp:550
#39 0x00007ffff715de01 in wxEntry (argc=<optimized out>, argv=<optimized out>) at ../src/common/init.cpp:577
#40 0x0000555555572392 in main (argc=<optimized out>, argv=<optimized out>) at ../../../samples/text/text.cpp:406

Patch or snippet allowing to reproduce the problem:

diff --git a/samples/text/text.cpp b/samples/text/text.cpp
index 38cdb3611c..17d640bec1 100644
--- a/samples/text/text.cpp
+++ b/samples/text/text.cpp
@@ -934,6 +934,8 @@ void MyTextCtrl::OnText(wxCommandEvent& event)
     {
         wxLogMessage("Text %s in some control", changeVerb);
     }
+
+    ChangeValue("Some other text");
 }
 
 void MyTextCtrl::OnTextEnter(wxCommandEvent& event)

To Reproduce:

In the text sample with the patch, Ctrl+A/select all text (I've been using the text box on the right), and paste some other text.

The clipboard content doesn't seem to matter when the whole text is selected and replaced via paste. When the whole text isn't selected, results seem to vary. Some cases it seems to crash, others it won't. Maybe "luck" with whatever goes out of bounds more than anything else...

Platform and version information

  • wxWidgets version you use: 3.3.3
  • wxWidgets port you use: wxGTK
  • OS and its version: Debian 13 Trixie
    • GTK version: 3.24.49
    • Which GDK backend is used: Wayland
    • Desktop environment : GNOME


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26742@github.com>

paulcor

unread,
Aug 3, 2026, 6:39:04 PM (19 hours ago) Aug 3
to wx-...@googlegroups.com, Subscribed
paulcor left a comment (wxWidgets/wxWidgets#26742)

Modifying the text from wxEVT_TEXT seems like a generally bad idea, and I don't see a way to get it to fully work with GTK. Maybe you could use CallAfter(). It is possible to avoid crashing though, so I have done that.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26742/5172492216@github.com>

Ryan Ogurek

unread,
Aug 3, 2026, 8:23:36 PM (17 hours ago) Aug 3
to wx-...@googlegroups.com, Subscribed
ryancog left a comment (wxWidgets/wxWidgets#26742)

Alrighty, that makes sense to me. Thanks for the band-aid.

CallAfter probably isn’t a bad recommendation. If I understand validators that seems like really the right choice.

But in any case, thanks again. I’ll double check things on my end, and (hopefully) close this then.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26742/5173155347@github.com>

Reply all
Reply to author
Forward
0 new messages