Skip to content

(Windows) _new() creates invalid Null instance of custom class / crashes in debug build #397

Closed

Description

@TheSHEEEP

(See this issue for reference)

On Linux the following line of my project works just fine:
https://github.com/TheSHEEEP/godotdetour/blob/master/src/detournavigation.cpp#L394

But on Windows, that _new() (and a couple others as well I assume) produce an invalid Null instance - and using that instance then goes on to cause crashes of course.

That is in a release build. In a debug build, it seems to crash during the _new() itself. Both the class's constructor and _init() function are called and executed without a crash, though.
I really cannot pinpoint where exactly the crash inside the _new() happens in a debug build.

You are of course very welcome to compile and run the demo of the module yourself to see the problem in action.

It is probably something wrong with my code, but given it all works fine on Linux, I'm a bit clueless as to what is going on.

Activity

  1. TheSHEEEP commented on Apr 17, 2020

    @TheSHEEEP
    Author

    As an additional info, I am using the version tagged as "3.2" in git (as it is for a 3.2 project).

  2. changed the title [-](Windows) _new() creates invalid Null instance - no errors[/-] [+](Windows) _new() creates invalid Null instance of custom class - no errors[/+] on Apr 17, 2020
  3. TheSHEEEP commented on Apr 20, 2020

    @TheSHEEEP
    Author

    Digging some further, even an empty custom class derived from Reference (no code other than one test function) will show this behavior, it seems as if on Windows, _new() simply will not produce anything usable.

    Could this be an incompatibility between Godot itself and MSVC2017?

    Using CustomClass.new() in GDScript works just fine and produces a usable instance, btw. Only in C++, _new() fails.

  4. TheSHEEEP commented on Apr 20, 2020

    @TheSHEEEP
    Author

    I was finally able to attach a debugger and show where inside of _new() the crash actually happens.
    This is the stack trace:

    1 Godot_v3_2_1_stable_win64 0x840f57
    2 Godot_v3_2_1_stable_win64 0x840ff0
    3 Godot_v3_2_1_stable_win64 0x28189b4
    4 godot::___godot_icall_bool __icalls.hpp 6224 0x7ffb0efa6014
    5 godot::Reference::init_ref Reference.cpp 31 0x7ffb0efa5f5a
    6 godot::Refgodot::DetourCrowdAgent::ref_pointer Ref.hpp 33 0x7ffb0eec43b1
    7 godot::Refgodot::DetourCrowdAgent::Refgodot::DetourCrowdAgent Ref.hpp 151 0x7ffb0eeb2673
    8 godot::DetourNavigation::addAgent detournavigation.cpp 395 0x7ffb0eebd496

    The crashing line inside of ___godot_icall_bool is this:
    godot::api->godot_method_bind_ptrcall(mb, inst->_owner, args, &ret);

    And the values at that point are:

    Locals
    args @0x433b188 void*[1]
    [0] 0x0 void*
    inst @0x10b31dd0 godot::Object
    [godot::_Wrapped] @0x10b31dd0 godot::_Wrapped
    _owner 0xdddddddddddddddd void*
    _type_tag 15987178197214944733 unsigned int64
    NOTIFICATION_POSTINITIALIZE
    NOTIFICATION_PREDELETE
    ___mb @0x7ffb0f291a10 godot::Object::___method_bindings
    mb @0x4b3be00 godot_method_bind
    _dont_touch_that "�" unsigned char[1]
    '¨' 168 0xa8 unsigned char
    ret true bool

  5. changed the title [-](Windows) _new() creates invalid Null instance of custom class - no errors[/-] [+](Windows) _new() creates invalid Null instance of custom class / crashes in debug build[/+] on Apr 20, 2020
  6. TheSHEEEP commented on Apr 20, 2020

    @TheSHEEEP
    Author

    After some help on the Discord, turns out this problem is known since last year... and there is a fix for it.

    Which hasn't been merged in many months.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions