Menu

#1907 Crash on GTK accessible

Bug
closed-fixed
5
2017-03-21
2017-02-04
No

A Geany user reported a crash in some specific scenario: https://github.com/geany/geany/issues/1385

I'm not certain why that scenario happens, but it's valid: if the acessible object is destroyed, but the associated widget isn't for some reason, it can lead to receiving a signal on a detsroyed accessible instance, thus to a crash.

Attached are 2 patches:

  • v1: this saves the handler ID and manually disconnect it. However, as the signal is automatically disconnected during the destruction of the instance on which it is registered, we also need to watch for automatic disconnection to avoid a warning when trying to disconnect in the destructor.
  • v2: uses g_signal_handlers_disconnect_by_data(), which disconnects all handlers matching the instance and the user data. This is great because it's simple and the logic of disconnecting any signal having a pointer to the destroyed object makes sense (although we oly have 1 currently); but g_signal_handlers_disconnect_by_data() is new in GLib 2.32 (March 24th, 2012). So you'll have to see whether this is an acceptable minimal dependency.
2 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2017-02-05

    It appears that g_signal_handlers_disconnect_by_data is just an easy-to-use macro over g_signal_handlers_disconnect_matched which is marked GLIB_AVAILABLE_IN_ALL so a call to g_signal_handlers_disconnect_matched could be used to avoid any dependency problems.

    #define g_signal_handlers_disconnect_by_data(instance, data) \
      g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data))
    
     
    • Colomban Wendling

      Yes, but I'm afraid that it wasn't valid to only match by data before 2.32, but I'm not sure. Though I don't have a system old enough to have 2.32 to check… maybe checking the code, I'll see if I can check that.

       
      • Colomban Wendling

        Yes, but I'm afraid that it wasn't valid to only match by data before
        2.32, but I'm not sure.

        I seem wrong, the code doesn't seem to have changed in that regard, so
        using disconnect_matches() seems like a good idea.

        I still couldn't test though.

        FTR, the upstream report that lead to the implementation of
        disconnect_by_data(): https://bugzilla.gnome.org/show_bug.cgi?id=668269

         
        • Colomban Wendling

          I still couldn't find something old enough not to have GLib 2.32 (Ubuntu 12.04 is too recent, which is the oldest thing I could still find a download for), but as said reading GLib's code suggests it should work with earlier versions too. Attached patch uses g_signal_handlers_disconnect_matched() and work fine for me.

           

          Last edit: Colomban Wendling 2017-02-07
          • Colomban Wendling

            Comment updated, apparently it was empty the first time.

             
  • Neil Hodgson

    Neil Hodgson - 2017-02-07
    • status: open --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2017-02-07

    Committed as [54cc0c].

    On my oldest system, Ubuntu 10.4, which no longer builds Scintilla for GTK+ 2.18 for other reasons, that line is OK.

     

    Related

    Commit: [54cc0c]

  • Neil Hodgson

    Neil Hodgson - 2017-02-20
    • status: open-fixed --> closed-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2017-02-26
    • status: closed-fixed --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2017-02-26

    Committed as [809112].

     

    Related

    Commit: [809112]

  • Neil Hodgson

    Neil Hodgson - 2017-03-21
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB