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 dangling Variants (3.2) #38119

Merged
merged 2 commits into from
Apr 24, 2020

Commits on Apr 23, 2020

  1. Avoid invocation to Object's copy constructor

    Needed for the next commit. That's the only place in all the Godot code base
    where that's attempted and it's not needed because Objects are not meant to
    be copied that way.
    RandomShaper committed Apr 23, 2020
    Configuration menu
    Copy the full SHA
    07c4dc1 View commit details
    Browse the repository at this point in the history
  2. Fix dangling and reassigned Variants

    This commit addresses multiple issues with `Variant`s that point to an `Object`
    which is later released, when it's tried to be accessed again.
    
    Formerly, **while running on the debugger the system would check if the instance id was
    still valid** to print warnings or return special values. Some cases weren't being
    warned about whatsoever.
    
    Also, a newly allocated `Object` could happen to be allocated at the same memory
    address of an old one, making cases of use hard to find and having **`Variant`s pointing
    to the old one magically reassigned to the new**.
    
    This commit makes the engine realize all these situations **under debugging**
    so you can detect and fix them. Running without a debugger attached will still
    behave as it always did.
    
    Also the warning messages have been extended and made clearer.
    
    All that said, in the name of performance there's still one possible case of undefined
    behavior: in multithreaded scripts there would be a race condition between a thread freeing
    an `Object` and another one trying to operate on it. The latter may not realize the
    `Object` has been freed soon enough. But that's a case of bad scripting that was never
    supported anyway.
    RandomShaper committed Apr 23, 2020
    Configuration menu
    Copy the full SHA
    d904d05 View commit details
    Browse the repository at this point in the history