Skip to content
  • Milan Crha's avatar
    ESimpleAsyncResult: Avoid thread scheduling race when finishing on idle · b4fa5a75
    Milan Crha authored
    The e_simple_async_result_complete_idle() adds a reference to the passed-in
    ESimpleAsyncResult instance and schedules an idle callback, where it is
    also unreffed. Usual follow up action of the caller was to unref the result,
    maybe in a dedicated thread. The race comes when the dedicated thread is
    suspended before it removes its reference on the result and the idle callback
    is processed before the thread is resumed. That can also mean to free
    widgets, which are supposed to be freed only in the main/UI thread,
    in the dedicated thread, causing crash or other issues. The fix is to
    take the reference of the result, instead of adding its own and unreffing
    it shortly after.
    
    This is related to a downstream bug report:
    https://bugzilla.redhat.com/show_bug.cgi?id=1770923
    b4fa5a75