Skip to content

[co19] LanguageFeatures/FinalizationRegistry/ffi/Finalizer/Finalizer_A01_t04 fails on all configurations #59752

@dcharkes

Description

@dcharkes

https://dart-current-results.web.app/#/filter=co19/LanguageFeatures/FinalizationRegistry/ffi/Finalizer/Finalizer_A01_t04&showAll

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.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions