-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
int called = 0;
final Finalizer finalizer = Finalizer((token) {
Expect.equals(123, token);
called++;
});
@pragma('vm:never-inline')
attachToFinalizer() async {
Object? liveObject;
Object object = Object();
finalizer.attach(object, 123);
await triggerGcWithDelay();
Expect.equals(0, called);
liveObject = object;
() async {
await triggerGcWithDelay();
Expect.equals(0, called); // `called = 1`
}();
print(liveObject);
}
main() async {
await attachToFinalizer();
// Previous triggerGc move some objects to old space. Do multiple GCs to
// force all objects to old space.
await triggerGcWithDelay(repeat: 3);
Expect.equals(1, called);
await triggerGcWithDelay();
Expect.equals(1, called);
}I'm pretty sure this test is wrong. For normal Finalizers that don't require the object to be Finalizable, we don't extend the lifetime to the end of the scope. So the object gets GCed early, leading to the expect failure.
cc @sgrekhov
Metadata
Metadata
Assignees
Labels
area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)