• Friedrich W. H. Kossebau's avatar
    subversion plugin: fix ThreadWeaver job lifetime race condition · a873e19b
    Friedrich W. H. Kossebau authored
    Summary:
    The old code had the internal ThreadWeaver job being killed via the QObject
    child memory management from the outer KJob-based job object.
    Though this was done based on a signal emitted from the ThreadWeaver
    execution thread, when the internal ThreadWeaver job was still going to be
    used by the internal reference in the execution completion code.
    
    While the actual current ThreadWeaver code then is not accessing any member
    data and just using the pointer to the otherwisse already deleted object,
    this at least is not liked by ASan which detects a heap-use-after-free,
    resulting e.g. in failing unit tests on CI now and then.
    
    This patch fixes this by passing the ThreadWeaver job instance via a
    QSHaredPointer which then is shared by both the parent KJob and the
    ThreadWeaver Queue, so the deletion will be done by the last one handling
    it.
    
    Test Plan: Subversion plugin still works for what I tested, unit tests still pass.
    
    Reviewers: #kdevelop, mwolff
    
    Reviewed By: #kdevelop, mwolff
    
    Subscribers: mwolff, kdevelop-devel
    
    Tags: #kdevelop
    
    Differential Revision: https://phabricator.kde.org/D14413
    a873e19b
svnjobbase.h 2.73 KB