Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dcharkes opened this issue Dec 18, 2024 · 2 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@dcharkes
Copy link
Contributor

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

@dart-github-bot
Copy link
Collaborator

Summary: A co19 test for FinalizationRegistry fails because it incorrectly assumes object lifetime extension beyond the scope. The test's expectation of finalizer execution timing is flawed.

@dart-github-bot dart-github-bot added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Dec 18, 2024
@sgrekhov sgrekhov self-assigned this Dec 18, 2024
@a-siva
Copy link
Contributor

a-siva commented Dec 18, 2024

Looks like the test has been fixed, closing this issue.

Usually we open a co19 issue when there is a problem with the test.

@a-siva a-siva closed this as completed Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants