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

Fix: Object::from_ref no longer forgetting to increment the strong count #5858

Merged
merged 3 commits into from
Oct 24, 2024

Commits on Oct 24, 2024

  1. Fix: Object::from_ref no longer forgetting to increment the strong co…

    …unt.
    
    Fixes #5851
    I haven't been able to produce consistently any program that could exhibit the issue this PR is solving, the only hint I had that this happened was the report of #5851, which I reasoned manually must come from this function that is being skipped. By making it opaque to the compiler, we prevent optimizations that would skip the strong count from increasing.
    Alternative to this would be to pass &Rc<Self> instead of &Self, which is what https://github.com/dafny-lang/dafny/tree/fix-object-safety-rust does, but &Rc does not make traits object-safe, which means we can't yet use them in the code.
    I tried also passing a second arguments so that we directly have a `Rc<>` and don't need to recover it from the &T, but `this: Rc<Self>` again makes the trait not object-safe, and `this: Rc<dyn Any>` causes an issue because we can't create this argument when what we have is only the trait, and trait upcast to Any is currently unsound in Rust.
    This PR is the best workaround I found so far.
    MikaelMayer committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    4f89b4a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    b0d7fee View commit details
    Browse the repository at this point in the history
  3. Fixed the CI test

    MikaelMayer committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    2442222 View commit details
    Browse the repository at this point in the history