It seems that removing the Qt::DirectConnection from Job::connectToArchiveInterfaceSignals() fixes the crash. For a rationale, see the comments by David in: https://git.reviewboard.kde.org/r/128113/
In particular:
I see what the problem is.
You're mixing KJob and QThread, which is only fine if none of the KJob API is called from the secondary thread. I.e. the KJob should only sit on top of the thread and report its progress (e.g. via signals emitted by the thread). This is almost what you're doing, except for this:
connect(archiveInterface(), &ReadOnlyArchiveInterface::finished, this, &Job::onFinished, Qt::DirectConnection);Due to the DirectConnection, this will call onFinished, and therefore KJob::emitResult, from the secondary thread. This leads to race conditions inside KJob, and it leads to deletion of the job happening in the wrong thread.
This should definitely not be a direct connection.This would also fix the race on m_isRunning that your code currently has (read/written in main thread (isRunning() and start()), but set to true in secondary thread in emitResult()).
TODO:
- Check whether this does not re-open bugs 193908 and 222392