Don't leak the debug session if a debug job finishes in destructor
The constructor of a MI debug job creates a debug session. A debug session emits finished() and is destroyed when it finishes. A MI debug job finishes normally when its debug session emits finished(). When a MI debug job is killed, it calls MIDebugSession::stopDebugger(), which finishes the debug session. However, when a MI debug job is destroyed before it starts running, the debug session is leaked. A job should never leak resources, no matter when or how it is destroyed. If a MIDebugJob has a dependency, GdbLauncher::start() adds the MIDebugJob as the second subjob of an ExecuteCompositeJob. If an ExecuteCompositeJob is configured to abort on error (which is the default and almost always the case), when a subjob finishes with an error, the remaining subjobs are never started, the composite job finishes and is soon destroyed. The remaining subjobs are owned by the composite job and are destroyed along with it. This scenario happens when a MIDebugJob job depends on a build job, and the build job fails, e.g. because of a syntax error in the program. Without this commit, the job's debug session is not destroyed and the Debug area remains active in KDevelop then. ExecuteCompositeJob::doKill() does not kill the remaining subjobs if killing a subjob fails. Since ExecuteCompositeJob is a parent of its subjobs, the not-killed subjobs are eventually destroyed along with it. Furthermore, I believe that not-started subjobs should always be simply destroyed rather than killed, and plan to implement this change soon. BUG: 394104 FIXED-IN: 5.11.230400
parent
10b277fb
Please register or sign in to comment