core: prevent scope parent-chain cycles when reusing pooled frames
- Scope.resetForReuse: fully detach before re-parenting (clear state, parent=null, new frameId), then validate with ensureNoCycle and assign parent/args/pos/thisObj - ScopePool.borrow (JVM/Android/JS/Native/Wasm): defensive fallback to fresh Scope allocation if resetForReuse detects a cycle - docs: add docs/fix-scope-parent-cycle.md describing the change and expectations - test: add ScopeCycleRegressionTest to ensure instance method call pattern does not crash and returns "ok"
This commit is contained in:
1 parent
b953282251
commit
d15dfb6087
8 files changed
+134
-28
No files matched your search
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Regression test for scope parent-chain cycle when reusing pooled frames
|
||||
*/
|
||||
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import net.sergeych.lyng.eval
|
||||
import kotlin.test.Test
|
||||
|
||||
class ScopeCycleRegressionTest {
|
||||
@Test
|
||||
fun instanceMethodCallDoesNotCycle() = runTest {
|
||||
eval(
|
||||
(
|
||||
"""
|
||||
class Whatever {
|
||||
fun something() {
|
||||
trace("something")
|
||||
}
|
||||
}
|
||||
|
||||
fun ll() { Whatever() }
|
||||
|
||||
fun callTest1() {
|
||||
val l = ll()
|
||||
l.something()
|
||||
"ok"
|
||||
}
|
||||
|
||||
assertEquals("ok", callTest1())
|
||||
"""
|
||||
).trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user