You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a function has two subsequent variable scopes with variables of different types then asm cannot infer whether the stack slots refer to references or not, thereby causing quasar instrumentation to omit incrementing either of idxObj or idxPrim in the InstrumentMethod.FrameInfo constructor. This causes the slots number in the frame record to be smaller than it should be, causing Stack.popMethod to leak references (if there are more objects in the function than primitives).
To reproduce:
importco.paralleluniverse.fibers.Fiberimportco.paralleluniverse.fibers.Stackimportco.paralleluniverse.fibers.Suspendableimportjava.util.concurrent.TimeUnitclassMyFiber : Fiber<Unit>() {
@Suspendable
overridefunrun() {
leaky()
val stackField =Fiber::class.java.getDeclaredField("stack")
stackField.isAccessible =trueval objectsField =Stack::class.java.getDeclaredField("dataObject")
objectsField.isAccessible =trueval stack = objectsField.get(stackField.get(this)) asArray<Any?>
println(stack.toList().take(10)) // prints nulls as well as "leaked"
}
@Suspendable
funleaky() {
val a =object {} // this is so that we have more objects than primitivesdo {
val leaked ="leaked"Fiber.park(1, TimeUnit.NANOSECONDS)
} while (false)
do {
val primitive =2Fiber.park(1, TimeUnit.NANOSECONDS)
} while (false)
}
}
funmain(args:Array<String>) {
MyFiber().start()
}
The text was updated successfully, but these errors were encountered:
The cause is that we clear the references on the stack in Stack.popMethod, but the number of slots to clear is taken from the current frame, which may not be the only frame in the method.
If a function has two subsequent variable scopes with variables of different types then asm cannot infer whether the stack slots refer to references or not, thereby causing quasar instrumentation to omit incrementing either of
idxObj
oridxPrim
in theInstrumentMethod.FrameInfo
constructor. This causes theslots
number in the frame record to be smaller than it should be, causingStack.popMethod
to leak references (if there are more objects in the function than primitives).To reproduce:
The text was updated successfully, but these errors were encountered: