Skip to content

Commit a0617d1

Browse files
committed
[lldb] Fix assert in ScriptedProcess destructor
This patch should fix a test failure in `Expr/TestIRMemoryMapWindows.test`: https://lab.llvm.org/buildbot/#/builders/219/builds/6786 The problem here is that since 7991412 landed, all the `ScriptInterpreter::CreateScripted*Interface` now return a `nullptr` when using the base `ScriptInterpreter` instance, instead of `ScriptInterpreterPython` for instance. This nullptr is actually well handled in the various places where we create a Scripted Interface, however, because of the way to instanciate a process, the process plugin manager have to iterate over every process plugin and call the `CreateInstance` static function that should instanciate the right object. So in the ScriptedProcess case, because we are getting a `nullptr` when trying to create a `ScriptedProcessInterface`, we try to discard the process object, which calls the Process destructor, which in turns calls the `ScriptedProcess` plugin `IsAlive` method. That method will fire an assertion if the scripted interface pointer is not allocated. This patch address that issue by returning early in the Scripted Process destructor, and not call `Finalize`, if the interface pointer is not valid. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 4a9c71b commit a0617d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ ScriptedProcess::ScriptedProcess(lldb::TargetSP target_sp,
130130

131131
ScriptedProcess::~ScriptedProcess() {
132132
Clear();
133+
// If the interface is not valid, we can't call Finalize(). When that happens
134+
// it means that the Scripted Process instanciation failed and the
135+
// CreateProcess function returns a nullptr, so no one besides this class
136+
// should have access to that bogus process object.
137+
if (!m_interface_up)
138+
return;
133139
// We need to call finalize on the process before destroying ourselves to
134140
// make sure all of the broadcaster cleanup goes as planned. If we destruct
135141
// this class, then Process::~Process() might have problems trying to fully

0 commit comments

Comments
 (0)