[Libreoffice-commits] core.git: vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Nov 13 13:25:14 UTC 2018


 vcl/unx/gtk3/gtk3gtkframe.cxx |   15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

New commits:
commit c3be773943d0d8800710cabf553969db3d7e7380
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Nov 13 10:35:20 2018 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Nov 13 14:24:46 2018 +0100

    GTK3: Make code robust against XAccessibleText::getCaretPosition returning -1
    
    ...which I've seen once cause the assert in rtl_uString_newFromSubString to fire
    when entering text ("foo") on a slide in Impress, see below.
    
    What also looks suspicious, though, is that both
    AccessibleEditableTextPara::getCaretPosition and
    AccessibleEditableTextPara::getText
    (editeng/source/accessibility/AccessibleEditableTextPara.cxx) each lock the
    SolarMutex first thing in their bodies, but from the below backtrace
    GtkSalFrame::IMHandler::signalIMRetrieveSurrounding appears to be called with
    SolarMutex not locked, so it smells like there could be a race and the call to
    getCaretPosition return a value unrelated to the value returned by the following
    call to getText.
    
    > #52 0x00007f4ae5e0e9f6 in __GI___assert_fail (assertion=0x7f4ae62ad22b "false", file=0x7f4ae62a026b "/data/sbergman/lo-clang2/core/sal/rtl/strtmpl.cxx", line=1378, function=0x7f4ae62a35e7 "void rtl_uString_newFromSubString(rtl_uString **, const rtl_uString *, sal_Int32, sal_Int32)") at /usr/src/debug/glibc-2.28/assert/assert.c:101
    > #53 0x00007f4ae6255157 in rtl_uString_newFromSubString(rtl_uString**, rtl_uString const*, sal_Int32, sal_Int32) (ppThis=0x7ffe871c1cd0, pFrom=0x15b24ed0, beginIndex=0, count=-1) at /data/sbergman/lo-clang2/core/sal/rtl/strtmpl.cxx:1378
    > #54 0x00007f4acabc861b in rtl::OUString::copy(int, int) const (this=0x7ffe871c1d88, beginIndex=0, count=-1) at /data/sbergman/lo-clang2/core/include/rtl/ustring.hxx:2221
    > #55 0x00007f4acac98dea in GtkSalFrame::IMHandler::signalIMRetrieveSurrounding(_GtkIMContext*, void*) (pContext=0xe188f20) at /data/sbergman/lo-clang2/core/vcl/unx/gtk3/gtk3gtkframe.cxx:4260
    > #60 0x00007f4ad94dbe04 in <emit signal 0x7f4aca793890 "retrieve-surrounding" on instance ???> (instance=0xe188f20, detailed_signal=detailed_signal at entry=0x7f4aca793890 "retrieve-surrounding") at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3487
    >     #56 0x00007f4aca75d206 in _gtk_marshal_BOOLEAN__VOID (closure=0x1594ccd0, return_value=0x7ffe871c1f40, n_param_values=<optimized out>, param_values=<optimized out>, invocation_hint=<optimized out>, marshal_data=<optimized out>) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkmarshalers.c:1901
    >     #57 0x00007f4ad94bec9d in g_closure_invoke (closure=0x1594ccd0, return_value=0x7ffe871c1f40, n_param_values=1, param_values=0x7ffe871c1fa0, invocation_hint=0x7ffe871c1f20) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gclosure.c:810
    >     #58 0x00007f4ad94d2203 in signal_emit_unlocked_R (node=node at entry=0x374ea40, detail=detail at entry=0, instance=instance at entry=0xe188f20, emission_return=emission_return at entry=0x7ffe871c20b0, instance_and_params=instance_and_params at entry=0x7ffe871c1fa0) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3635
    >     #59 0x00007f4ad94da9a3 in g_signal_emit_valist (instance=instance at entry=0xe188f20, signal_id=signal_id at entry=255, detail=detail at entry=0, var_args=var_args at entry=0x7ffe871c21a8) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3401
    > #61 0x00007f4aca5a55dc in gtk_im_multicontext_retrieve_surrounding_cb (slave=slave at entry=0x367b5f0, multicontext=<optimized out>) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkimmulticontext.c:532
    > #66 0x00007f4ad94dbe04 in <emit signal 0x7f4aca793890 "retrieve-surrounding" on instance ???> (instance=0x367b5f0, detailed_signal=detailed_signal at entry=0x7f4aca793890 "retrieve-surrounding") at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3487
    >     #62 0x00007f4aca75d206 in _gtk_marshal_BOOLEAN__VOID (closure=0x15949020, return_value=0x7ffe871c2490, n_param_values=<optimized out>, param_values=<optimized out>, invocation_hint=<optimized out>, marshal_data=<optimized out>) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkmarshalers.c:1901
    >     #63 0x00007f4ad94bec9d in g_closure_invoke (closure=0x15949020, return_value=0x7ffe871c2490, n_param_values=1, param_values=0x7ffe871c24f0, invocation_hint=0x7ffe871c2470) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gclosure.c:810
    >     #64 0x00007f4ad94d2203 in signal_emit_unlocked_R (node=node at entry=0x374ea40, detail=detail at entry=0, instance=instance at entry=0x367b5f0, emission_return=emission_return at entry=0x7ffe871c2600, instance_and_params=instance_and_params at entry=0x7ffe871c24f0) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3635
    >     #65 0x00007f4ad94da9a3 in g_signal_emit_valist (instance=instance at entry=0x367b5f0, signal_id=signal_id at entry=255, detail=detail at entry=0, var_args=var_args at entry=0x7ffe871c26f8) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3401
    > #67 0x00007f4aca76673c in released_cb (gesture=<optimized out>, n_press=1, x=535, y=1009, context=0x367b5f0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/modules/input/imwayland.c:523
    > #68 0x00007f4ad8b45ace in ffi_call_unix64 () at /usr/src/debug/libffi-3.1-18.fc29.x86_64/src/x86/unix64.S:76
    > #69 0x00007f4ad8b4548f in ffi_call (cif=cif at entry=0x7ffe871c2a80, fn=fn at entry=0x7f4aca766660 <released_cb>, rvalue=<optimized out>, avalue=avalue at entry=0x7ffe871c2990) at /usr/src/debug/libffi-3.1-18.fc29.x86_64/src/x86/ffi64.c:525
    > #70 0x00007f4ad94bfc66 in g_cclosure_marshal_generic_va (closure=<optimized out>, return_value=<optimized out>, instance=<optimized out>, args_list=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=<optimized out>) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gclosure.c:1610
    > #71 0x00007f4ad94beef6 in _g_closure_invoke_va (closure=0x158f4a50, return_value=0x0, instance=0x159474c0, args=0x7ffe871c2d30, n_params=3, param_types=0x34f2830) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gclosure.c:873
    > #72 0x00007f4ad94db381 in g_signal_emit_valist (instance=0x159474c0, signal_id=<optimized out>, detail=0, var_args=var_args at entry=0x7ffe871c2d30) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3300
    > #73 0x00007f4ad94db923 in g_signal_emit (instance=instance at entry=0x159474c0, signal_id=<optimized out>, detail=detail at entry=0) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3447
    > #74 0x00007f4aca57bdfc in gtk_gesture_multi_press_end (gesture=0x159474c0, sequence=<optimized out>) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkgesturemultipress.c:286
    > #75 0x00007f4ad94c206e in g_cclosure_marshal_VOID__BOXEDv (closure=0x34ec650, return_value=<optimized out>, instance=<optimized out>, args=<optimized out>, marshal_data=<optimized out>, n_params=<optimized out>, param_types=0x34ec680) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gmarshal.c:1950
    > #76 0x00007f4ad94beef6 in _g_closure_invoke_va (closure=0x34ec650, return_value=0x0, instance=0x159474c0, args=0x7ffe871c30f0, n_params=1, param_types=0x34ec680) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gclosure.c:873
    > #77 0x00007f4ad94db381 in g_signal_emit_valist (instance=0x159474c0, signal_id=<optimized out>, detail=0, var_args=var_args at entry=0x7ffe871c30f0) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3300
    > #78 0x00007f4ad94db923 in g_signal_emit (instance=instance at entry=0x159474c0, signal_id=<optimized out>, detail=detail at entry=0) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/gobject/gsignal.c:3447
    > #79 0x00007f4aca578f02 in _gtk_gesture_set_recognized (sequence=0x0, recognized=0, gesture=0x159474c0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkgesture.c:345
    > #80 0x00007f4aca578f02 in _gtk_gesture_check_recognized (gesture=gesture at entry=0x159474c0, sequence=sequence at entry=0x0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkgesture.c:386
    > #81 0x00007f4aca57a50b in gtk_gesture_handle_event (controller=0x159474c0, event=0x7f4ab0006bd0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkgesture.c:814
    > #82 0x00007f4aca57d40e in gtk_gesture_single_handle_event (controller=0x159474c0, event=0x7f4ab0006bd0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkgesturesingle.c:222
    > #83 0x00007f4aca545235 in gtk_event_controller_handle_event (controller=0x159474c0, event=event at entry=0x7f4ab0006bd0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkeventcontroller.c:230
    > #84 0x00007f4aca70538b in _gtk_widget_run_controllers (widget=widget at entry=0x38272a0, event=event at entry=0x7f4ab0006bd0, phase=phase at entry=GTK_PHASE_CAPTURE) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkwidget.c:7379
    > #85 0x00007f4aca70992b in _gtk_widget_captured_event (widget=widget at entry=0x38272a0, event=event at entry=0x7f4ab0006bd0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkwidget.c:7433
    > #86 0x00007f4aca5c394b in propagate_event_down (topmost=0x0, event=0x7f4ab0006bd0, widget=0x38272a0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkmain.c:2636
    > #87 0x00007f4aca5c394b in propagate_event (widget=widget at entry=0x38272a0, event=event at entry=0x7f4ab0006bd0, captured=captured at entry=1, topmost=topmost at entry=0x0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkmain.c:2684
    > #88 0x00007f4aca5c5957 in _gtk_propagate_captured_event (topmost=0x0, event=0x7f4ab0006bd0, widget=0x38272a0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkmain.c:2727
    > #89 0x00007f4aca5c5957 in gtk_main_do_event (event=<optimized out>) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gtk/gtkmain.c:1914
    > #90 0x00007f4aca2b6a39 in _gdk_event_emit (event=event at entry=0x7f4ab0006bd0) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gdk/gdkevents.c:73
    > #91 0x00007f4aca313286 in gdk_event_source_dispatch (base=<optimized out>, callback=<optimized out>, data=<optimized out>) at /usr/src/debug/gtk3-3.24.1-1.fc29.x86_64/gdk/wayland/gdkeventsource.c:124
    > #92 0x00007f4ad93dd26d in g_main_dispatch (context=0x239de80) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/glib/gmain.c:3182
    > #93 0x00007f4ad93dd26d in g_main_context_dispatch (context=context at entry=0x239de80) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/glib/gmain.c:3847
    > #94 0x00007f4ad93dd638 in g_main_context_iterate (context=context at entry=0x239de80, block=block at entry=1, dispatch=dispatch at entry=1, self=<optimized out>) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/glib/gmain.c:3920
    > #95 0x00007f4ad93dd6d0 in g_main_context_iteration (context=0x239de80, may_block=1) at /usr/src/debug/glib2-2.58.1-1.fc29.x86_64/glib/gmain.c:3981
    > #96 0x00007f4acaba22db in GtkSalData::Yield(bool, bool) (this=0x2249a70, bWait=true, bHandleAllCurrentEvents=false) at /data/sbergman/lo-clang2/core/vcl/unx/gtk3/gtk3gtkdata.cxx:463
    > #97 0x00007f4acaba6a67 in GtkInstance::DoYield(bool, bool) (this=0x225b3c0, bWait=true, bHandleAllCurrentEvents=false) at /data/sbergman/lo-clang2/core/vcl/unx/gtk/gtkinst.cxx:406
    > #98 0x00007f4adf166c6a in ImplYield(bool, bool) (i_bWait=true, i_bAllEvents=false) at /data/sbergman/lo-clang2/core/vcl/source/app/svapp.cxx:438
    > #99 0x00007f4adf166a14 in Application::Yield() () at /data/sbergman/lo-clang2/core/vcl/source/app/svapp.cxx:502
    > #100 0x00007f4adf1669a6 in Application::Execute() () at /data/sbergman/lo-clang2/core/vcl/source/app/svapp.cxx:419
    > #101 0x00007f4ae601eba1 in desktop::Desktop::Main() (this=0x7ffe871c4600) at /data/sbergman/lo-clang2/core/desktop/source/app/app.cxx:1636
    > #102 0x00007f4adf182b45 in ImplSVMain() () at /data/sbergman/lo-clang2/core/vcl/source/app/svmain.cxx:199
    > #103 0x00007f4adf1843d9 in SVMain() () at /data/sbergman/lo-clang2/core/vcl/source/app/svmain.cxx:233
    > #104 0x00007f4ae608e9b8 in soffice_main() () at /data/sbergman/lo-clang2/core/desktop/source/app/sofficemain.cxx:169
    > #105 0x00000000004011ab in sal_main () at /data/sbergman/lo-clang2/core/desktop/source/app/main.c:48
    > #106 0x00000000004011ab in main (argc=<optimized out>, argc at entry=1, argv=<optimized out>, argv at entry=0x7ffe871c4908) at /data/sbergman/lo-clang2/core/desktop/source/app/main.c:47
    > (gdb) frame 55
    > #55 0x00007f4acac98dea in GtkSalFrame::IMHandler::signalIMRetrieveSurrounding (pContext=0xe188f20) at /data/sbergman/lo-clang2/core/vcl/unx/gtk3/gtk3gtkframe.cxx:4260
    > 4260          OUString sCursorText(sAllText.copy(0, nPosition));
    > (gdb) print xText
    > $1 = uno::Reference to (accessibility::AccessibleEditableTextPara *) 0x1597a418
    > (gdb) print nPosition
    > $2 = -1
    > (gdb) print sAllText
    > $3 = "foo"
    
    Change-Id: I047f0932bf7f44da58c6f701695b4f3e0fb0adfa
    Reviewed-on: https://gerrit.libreoffice.org/63324
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index bb1cbf48b569..4e5271801b4d 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -4255,12 +4255,15 @@ gboolean GtkSalFrame::IMHandler::signalIMRetrieveSurrounding( GtkIMContext* pCon
     if (xText.is())
     {
         sal_Int32 nPosition = xText->getCaretPosition();
-        OUString sAllText = xText->getText();
-        OString sUTF = OUStringToOString(sAllText, RTL_TEXTENCODING_UTF8);
-        OUString sCursorText(sAllText.copy(0, nPosition));
-        gtk_im_context_set_surrounding(pContext, sUTF.getStr(), sUTF.getLength(),
-            OUStringToOString(sCursorText, RTL_TEXTENCODING_UTF8).getLength());
-        return true;
+        if (nPosition != -1)
+        {
+            OUString sAllText = xText->getText();
+            OString sUTF = OUStringToOString(sAllText, RTL_TEXTENCODING_UTF8);
+            OUString sCursorText(sAllText.copy(0, nPosition));
+            gtk_im_context_set_surrounding(pContext, sUTF.getStr(), sUTF.getLength(),
+                OUStringToOString(sCursorText, RTL_TEXTENCODING_UTF8).getLength());
+            return true;
+        }
     }
 
     return false;


More information about the Libreoffice-commits mailing list