IDEA-368394 Leaking VirtualMachineImpl via CoroutineScopeExtractor

(cherry picked from commit f3895a1281c96f3574a062f05160853bb92713f1)

IJ-CR-156483

GitOrigin-RevId: 69fd279c6d1b79d1de453ea8cd99366f4ab789bc
This commit is contained in:
Egor Ushakov
2025-02-28 16:28:02 +01:00
committed by intellij-monorepo-bot
parent 50d7ed3e0c
commit b98f6784a8

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.debugger.coroutine.proxy
@@ -8,6 +8,7 @@ import com.intellij.debugger.engine.SuspendManagerUtil
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
import com.intellij.debugger.jdi.StackFrameProxyImpl
import com.intellij.debugger.jdi.ThreadReferenceProxyImpl
import com.intellij.openapi.util.getOrCreateUserData
import com.sun.jdi.Location
import com.sun.jdi.ObjectReference
import com.sun.jdi.StackFrame
@@ -57,10 +58,8 @@ class CoroutineStackFrameProxyImpl(
val debugProcess = virtualMachine.debugProcess as? DebugProcessImpl ?: return null
val suspendContext = SuspendManagerUtil.getContextForEvaluation(debugProcess.suspendManager) ?: return null
val evaluationContext = EvaluationContextImpl(suspendContext, this)
val extractor = debugProcess.getUserData(CoroutineScopeExtractor.KEY) ?: run {
val newExtractor = CoroutineScopeExtractor.create(evaluationContext)
debugProcess.putUserData(CoroutineScopeExtractor.KEY, newExtractor)
newExtractor
val extractor = virtualMachine.getOrCreateUserData(CoroutineScopeExtractor.KEY) {
CoroutineScopeExtractor.create(evaluationContext)
}
return extractor.extractCoroutineScope(continuation, evaluationContext)
}