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

crash on GridMap::set_mesh_library(); #984

Open
RonYanDaik opened this issue Sep 22, 2024 · 7 comments
Open

crash on GridMap::set_mesh_library(); #984

RonYanDaik opened this issue Sep 22, 2024 · 7 comments
Labels
needs triage Something that needs investigation

Comments

@RonYanDaik
Copy link

RonYanDaik commented Sep 22, 2024

in editor if calling set_mesh_library on a grid that has already items it crashes.
this where debugger leads:
image

godot version: 4.3
godot-joilt: 0.13.0

callstack:

~godot-jolt_windows-x64_editor.dll!00007ffcc883bbd1() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc87fdb00() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc87da119() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc8741baa() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc8688645() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc861afcf() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc861c89a() (Unknown Source:0)
~godot-jolt_windows-x64_editor.dll!00007ffcc8635dfe() (Unknown Source:0)
godot.windows.editor.dev.x86_64.exe!PhysicsServer3DExtension::_gdvirtual__body_set_space_call<1>(RID arg1, RID arg2) Line 292 (..path\Godot\servers\extensions\physics_server_3d_extension.h:292)
godot.windows.editor.dev.x86_64.exe!PhysicsServer3DExtension::body_set_space(RID arg1, RID arg2) Line 292 (..path\Godot\servers\extensions\physics_server_3d_extension.h:292)
godot.windows.editor.dev.x86_64.exe!GridMap::_octant_enter_world(const GridMap::OctantKey & p_key) Line 766 (..path\Godot\modules\gridmap\grid_map.cpp:766)
godot.windows.editor.dev.x86_64.exe!GridMap::set_cell_item(const Vector3i & p_position, int p_item, int p_rot) Line 386 (..path\Godot\modules\gridmap\grid_map.cpp:386)
godot.windows.editor.dev.x86_64.exe!GridMap::_recreate_octant_data() Line 997 (..path\Godot\modules\gridmap\grid_map.cpp:997)
godot.windows.editor.dev.x86_64.exe!GridMap::set_mesh_library(const Ref<MeshLibrary> & p_mesh_library) Line 267 (..path\Godot\modules\gridmap\grid_map.cpp:267)
godot.windows.editor.dev.x86_64.exe!call_with_ptr_args_helper<GridMap,Ref<MeshLibrary> const &,0>(GridMap * p_instance, void(GridMap::*)(const Ref<MeshLibrary> &) p_method, const void * * p_args, IndexSequence<0> __formal) Line 325 (..path\Godot\core\variant\binder_common.h:325)
godot.windows.editor.dev.x86_64.exe!call_with_ptr_args<GridMap,Ref<MeshLibrary> const &>(GridMap * p_instance, void(GridMap::*)(const Ref<MeshLibrary> &) p_method, const void * * p_args) Line 573 (..path\Godot\core\variant\binder_common.h:573)
godot.windows.editor.dev.x86_64.exe!MethodBindT<GridMap,Ref<MeshLibrary> const &>::ptrcall(Object * p_object, const void * * p_args, void * r_ret) Line 366 (..path\Godot\core\object\method_bind.h:366)
godot.windows.editor.dev.x86_64.exe!gdextension_object_method_bind_ptrcall(const void * p_method_bind, void * p_instance, const void * const * p_args, void * p_ret) Line 1222 (..path\Godot\core\extension\gdextension_interface.cpp:1222)

@github-actions github-actions bot added the needs triage Something that needs investigation label Sep 22, 2024
@mihe
Copy link
Contributor

mihe commented Sep 22, 2024

Would you mind downloading the debug symbols (godot-jolt_v0.13.0-stable_symbols.zip) from the release page and extracting them so that the *.pdb files end up alongside their respective *.dll files?

That way you should get an actual callstack for the extension part of it.

If you're able to provide some kind of minimal reproduction project, so that I can reproduce it on my end, I would appreciate that as well.

@RonYanDaik
Copy link
Author

I've donwloaded pdbs:


~godot-jolt_windows-x64_editor.dll!abort() Line 77 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\minkernel\crts\ucrt\src\appcrt\startup\abort.cpp:77)
[Inline Frame] ~godot-jolt_windows-x64_editor.dll!JPH::QuadTree::AllocateNode(bool inIsChanged) Line 195 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\jolt\Jolt\Physics\Collision\BroadPhase\QuadTree.cpp:195)
~godot-jolt_windows-x64_editor.dll!JPH::QuadTree::TryCreateNewRoot(JPH::Array<JPH::QuadTree::Tracking,JPH::STLAllocator<JPH::QuadTree::Tracking>> & ioTracking, std::atomic<unsigned int> & ioRootNodeIndex, JPH::QuadTree::NodeID inLeafID, const JPH::AABox & inLeafBounds, int inLeafNumBodies) Line 788 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\jolt\Jolt\Physics\Collision\BroadPhase\QuadTree.cpp:788)
[Inline Frame] ~godot-jolt_windows-x64_editor.dll!JPH::QuadTree::AddBodiesFinalize(JPH::Array<JPH::QuadTree::Tracking,JPH::STLAllocator<JPH::QuadTree::Tracking>> & ioTracking, int inNumberBodies, const JPH::QuadTree::AddState & inState) Line 830 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\jolt\Jolt\Physics\Collision\BroadPhase\QuadTree.cpp:830)
~godot-jolt_windows-x64_editor.dll!JPH::BroadPhaseQuadTree::AddBodiesFinalize(JPH::BodyID * ioBodies, int inNumber, void * inAddState) Line 225 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\jolt\Jolt\Physics\Collision\BroadPhase\BroadPhaseQuadTree.cpp:225)
~godot-jolt_windows-x64_editor.dll!JPH::BodyInterface::AddBody(const JPH::BodyID & inBodyID, JPH::EActivation inActivationMode) Line 134 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\jolt\Jolt\Physics\Body\BodyInterface.cpp:134)
[Inline Frame] ~godot-jolt_windows-x64_editor.dll!JPH::BodyInterface::CreateAndAddBody(const JPH::BodyCreationSettings & inSettings, JPH::EActivation inActivationMode) Line 167 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\jolt\Jolt\Physics\Body\BodyInterface.cpp:167)
~godot-jolt_windows-x64_editor.dll!JoltSpace3D::add_rigid_body(const JoltObjectImpl3D & p_object, const JPH::BodyCreationSettings & p_settings) Line 375 (d:\a\godot-jolt\godot-jolt\src\spaces\jolt_space_3d.cpp:375)
~godot-jolt_windows-x64_editor.dll!JoltBodyImpl3D::_add_to_space() Line 1153 (d:\a\godot-jolt\godot-jolt\src\objects\jolt_body_impl_3d.cpp:1153)
~godot-jolt_windows-x64_editor.dll!JoltObjectImpl3D::set_space(JoltSpace3D * p_space) Line 48 (d:\a\godot-jolt\godot-jolt\src\objects\jolt_object_impl_3d.cpp:48)
~godot-jolt_windows-x64_editor.dll!godot::call_with_ptr_args_helper<JoltPhysicsServer3D,const godot::RID &,const godot::RID &,0,1>(JoltPhysicsServer3D * p_instance, void(JoltPhysicsServer3D::*)(const godot::RID &, const godot::RID &) p_method, const void * const * p_args, IndexSequence<0,1>) Line 195 (d:\a\godot-jolt\godot-jolt\build\windows-clangcl-x64\External\Source\godot-cpp\include\godot_cpp\core\binder_common.hpp:195)
godot.windows.editor.dev.x86_64.exe!PhysicsServer3DExtension::_gdvirtual__body_set_space_call<1>(RID arg1, RID arg2) Line 292 (d:\..path\Godot\servers\extensions\physics_server_3d_extension.h:292)
godot.windows.editor.dev.x86_64.exe!PhysicsServer3DExtension::body_set_space(RID arg1, RID arg2) Line 292 (d:\..path\Godot\servers\extensions\physics_server_3d_extension.h:292)
godot.windows.editor.dev.x86_64.exe!GridMap::_octant_enter_world(const GridMap::OctantKey & p_key) Line 766 (d:\..path\Godot\modules\gridmap\grid_map.cpp:766)
godot.windows.editor.dev.x86_64.exe!GridMap::set_cell_item(const Vector3i & p_position, int p_item, int p_rot) Line 386 (d:\..path\Godot\modules\gridmap\grid_map.cpp:386)
godot.windows.editor.dev.x86_64.exe!GridMap::_recreate_octant_data() Line 997 (d:\..path\Godot\modules\gridmap\grid_map.cpp:997)
godot.windows.editor.dev.x86_64.exe!GridMap::set_mesh_library(const Ref<MeshLibrary> & p_mesh_library) Line 267 (d:\..path\Godot\modules\gridmap\grid_map.cpp:267)
godot.windows.editor.dev.x86_64.exe!call_with_ptr_args_helper<GridMap,Ref<MeshLibrary> const &,0>(GridMap * p_instance, void(GridMap::*)(const Ref<MeshLibrary> &) p_method, const void * * p_args, IndexSequence<0> __formal) Line 325 (d:\..path\Godot\core\variant\binder_common.h:325)
godot.windows.editor.dev.x86_64.exe!call_with_ptr_args<GridMap,Ref<MeshLibrary> const &>(GridMap * p_instance, void(GridMap::*)(const Ref<MeshLibrary> &) p_method, const void * * p_args) Line 573 (d:\..path\Godot\core\variant\binder_common.h:573)
godot.windows.editor.dev.x86_64.exe!MethodBindT<GridMap,Ref<MeshLibrary> const &>::ptrcall(Object * p_object, const void * * p_args, void * r_ret) Line 366 (d:\..path\Godot\core\object\method_bind.h:366)

@mihe
Copy link
Contributor

mihe commented Sep 23, 2024

@jrouwe It's not clear to me how one reliably avoids this std::abort in QuadTree::AllocateNode, other than to make use of AddBodiesPrepare and whatnot.

I'm assuming I can call JoltSpace3D::try_optimize as part of JoltSpace3D::add_rigid_body as a way to resolve this, since that'll discard the old trees, but seeing as how the FixedSizeFreeList in BroadPhaseQuadTree is initialized based on the max number of bodies I'm guessing there's still a theoretical possibility of crashing anyway if one sets that low enough?

@jrouwe
Copy link
Contributor

jrouwe commented Sep 23, 2024

I'm assuming I can call JoltSpace3D::try_optimize as part of JoltSpace3D::add_rigid_body as a way to resolve this, since that'll discard the old trees

I'm suspecting that the reason this is crashing is that we're quite close to the max number of bodies. I think it would be good to see first why it is triggering this. Calling OptimizeBroadPhase for every 128th body added could slow down things quite considerably.

@RonYanDaik
Copy link
Author

RonYanDaik commented Sep 23, 2024

A little clarification:
If I recreate GridMap instead of reusing it and fill it with items the crash can be avoided.
Also this GridMap actually has no collision. (But I have other GridMap in the scene that have collison).

I think I'll try to make a reproduction project.

@jrouwe
Copy link
Contributor

jrouwe commented Sep 26, 2024

B.t.w. the 'fix' could be as simple as increasing the Max Bodies:

image

@mihe
Copy link
Contributor

mihe commented Oct 17, 2024

@RonYanDaik Were you able to create some sort of reproduction project for this issue, or experiment with raising the max number of bodies, as suggested above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Something that needs investigation
Projects
None yet
Development

No branches or pull requests

3 participants