Skip to content

_instance_bindings is initialized multiple times #679

Closed

Description

@saki7

Forked from #668

Error summary

ERROR: Condition "_instance_bindings != nullptr" is true.
   at: Object::set_instance_binding (core\object\object.cpp:1781)

Steps to reproduce

Scene tree:

  • TestContainer
    • Node

Extension code:

class TestContainer : public Node
{
    GDCLASS(TestContainer, Node);

public:
    static void _bind_methods() {}

    void _ready() override
    {
        WARN_PRINT("TestContainer::_ready()");
        get_node<Node>("Node"); // <-----------------------------------
    }
};

Note that I picked get_node solely as an example here; all other functions which access the instance binding object may trigger the same issue.

My findings

When Object::get_instance_binding is called before Object::set_instance_binding, godot core fallbacks to newly created instance (object.cpp#L1799-L1815). I am suspecting that fallback instance is reason for multiple initialization in Wrapped::_postinitialize. If that's the case, we must fix the godot core first, then fix godot-cpp accordingly.

Activity

  1. added
    bug
    topic:gdextension
    on Jan 6, 2022
  2. saki7 commented on Jul 11, 2022

    @saki7
    ContributorAuthor

    I've rebuilt godot and godot-cpp on current master (godotengine/godot@9b3972a) but the _instance_bindings assertion errors are still flooding my console.

    I have also confirmed that the workaround I posted on #668 (comment) is working, however I'm not sure if it is the correct fix (see the caveat mentioned by vnen, #668 (comment))

    I really want to propose an appropriate fix for this, but I'm still not sure where the multiple initialization of _instance_bindings comes from.

  3. added this to the 4.0 milestone on Jul 29, 2022
  4. Kev commented on Jul 29, 2022

    @Kev
    Contributor

    Unless I massively screwed up, I'm running with godot 5ca09b322c0dea3f71de3239c2da2a72d987f67d and godot-cpp 9aa129c and I'm still seeing a lot of 'Condition "_instance_bindings != nullptr" is true.' - these commits shouldn't be showing this any more should they?

  5. Kev commented on Jul 29, 2022

    @Kev
    Contributor

    Very sorry - the library rename meant I was running my old dylib, not the new one. Ignore the report - no sign of this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtopic:gdextension

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions