GNOME Bugzilla – Bug 726689
Signal marshalling of string + length (GtkTextBuffer::insert-text)
Last modified: 2018-01-10 20:38:12 UTC
We're encountering a crasher bug in gedit which is due to the closure marshalling of the insert-text signal on a GtkTextBuffer. I don't know if this is a gtk+ annotation problem, or also a pygobject issue (I glanced over the code, and it seems it would need some adaptation also). In gedit there are some cases in which we call gtk_text_buffer_insert_text with a non-null terminated buffer, specifying the length of text to be inserted explicitly. However, when we have signal handlers installed in python for the insert-text signal, gedit crashes due to the fact that the string argument fails to get marshalled to a python unicode string (since it's not null terminated).
By changing the annotation of the 'insert-text' signal to use the length argument, I think you will then hit bug 694735 (related to bug 694448). Changing the buffer to a uint8 array explicitly probably be an API break for the 'insert-text' signal. One fix would just be to make sure specifying the length arg for char pointers generates a better GIR (string+length) as originally thought in bug 694735... From the PyGObject side of things, I'm pretty sure signals with array lengths work for input args, but there might be a few tweaks. There are a few noted bugs but I think they are related to output array args (bug 669496 and bug 702508).
Yes, it looks like supporting string+length would be a nice fix. In the mean time, I think we'll try to make sure that the buffer we pass to insert-text is always 0 terminated, just to make sure we don't crash.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/68.