forked from OSchip/llvm-project
Call DeleteCurrentProcess before we replace the old process.
We need to ensure that Finalize gets called before we start to destroy the old Process or the weak_ptr->shared_ptr link from Threads to Target gets broken before the threads are destroyed. <rdar://problem/43586979> Differential Revision: https://reviews.llvm.org/D55631 llvm-svn: 349435
This commit is contained in:
parent
f457470286
commit
362d022d60
|
@ -2864,22 +2864,15 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
|
||||||
log->Printf("Target::%s asking the platform to debug the process",
|
log->Printf("Target::%s asking the platform to debug the process",
|
||||||
__FUNCTION__);
|
__FUNCTION__);
|
||||||
|
|
||||||
// Get a weak pointer to the previous process if we have one
|
// If there was a previous process, delete it before we make the new one.
|
||||||
ProcessWP process_wp;
|
// One subtle point, we delete the process before we release the reference
|
||||||
if (m_process_sp)
|
// to m_process_sp. That way even if we are the last owner, the process
|
||||||
process_wp = m_process_sp;
|
// will get Finalized before it gets destroyed.
|
||||||
|
DeleteCurrentProcess();
|
||||||
|
|
||||||
m_process_sp =
|
m_process_sp =
|
||||||
GetPlatform()->DebugProcess(launch_info, debugger, this, error);
|
GetPlatform()->DebugProcess(launch_info, debugger, this, error);
|
||||||
|
|
||||||
// Cleanup the old process since someone might still have a strong
|
|
||||||
// reference to this process and we would like to allow it to cleanup as
|
|
||||||
// much as it can without the object being destroyed. We try to lock the
|
|
||||||
// shared pointer and if that works, then someone else still has a strong
|
|
||||||
// reference to the process.
|
|
||||||
|
|
||||||
ProcessSP old_process_sp(process_wp.lock());
|
|
||||||
if (old_process_sp)
|
|
||||||
old_process_sp->Finalize();
|
|
||||||
} else {
|
} else {
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf("Target::%s the platform doesn't know how to debug a "
|
log->Printf("Target::%s the platform doesn't know how to debug a "
|
||||||
|
|
Loading…
Reference in New Issue