Repository: godot
Issue: Crash in GodotConvexPolygonShape3D when running physics on separate thread
Labels: bug,topic:physics,needs testing,crash

### Tested versions

HEAD
4.3 beta 1

### System information

Reproductible on both Windows and Linux

### Issue description

Running 3D physics on a separate thread can lead to crashes during startup, when changing resolution and probably some other lifecycle events.

The `GodotConvexPolygonShape3D::get_support` can start executing when `::_setup` has not finished and `extreme_vertices` or `vertex_neighbors` have not yet been populated.

### Steps to reproduce

1. Take a scene using SpringArm3D - e.g.: https://godotengine.org/asset-library/asset/2268
1. Enable `physics/3d/run_on_separate_thread`
1. Add logic to maximize the game by pressing Alt-Enter
1. Run and change the resolution couple of times
1. Observe a crash

```
godot.windows.editor.dev.x86_64.exe!LocalVector<LocalVector<int,unsigned int,0,0>,unsigned int,0,0>::operator[](unsigned int p_index) Line 173
	at core\templates\local_vector.h(173)
godot.windows.editor.dev.x86_64.exe!GodotConvexPolygonShape3D::get_support(const Vector3 & p_normal) Line 888
	at servers\physics_3d\godot_shape_3d.cpp(888)
godot.windows.editor.dev.x86_64.exe!GodotMotionShape3D::get_support(const Vector3 & p_normal) Line 495
	at servers\physics_3d\godot_shape_3d.h(495)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::MinkowskiDiff::get_support_without_margin(const GodotShape3D * p_shape, const Vector3 & p_dir, float p_margin) Line 135
	at servers\physics_3d\gjk_epa.cpp(135)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::MinkowskiDiff::Support0(const Vector3 & d) Line 150
	at servers\physics_3d\gjk_epa.cpp(150)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::MinkowskiDiff::Support(const Vector3 & d) Line 158
	at servers\physics_3d\gjk_epa.cpp(158)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::GJK::getsupport(const Vector3 & d, GjkEpa2::GJK::sSV & sv) Line 413
	at servers\physics_3d\gjk_epa.cpp(413)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::GJK::appendvertice(GjkEpa2::GJK::sSimplex & simplex, const Vector3 & v) Line 424
	at servers\physics_3d\gjk_epa.cpp(424)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::GJK::Evaluate(const GjkEpa2::MinkowskiDiff & shapearg, const Vector3 & guess) Line 237
	at servers\physics_3d\gjk_epa.cpp(237)
godot.windows.editor.dev.x86_64.exe!GjkEpa2::Distance(const GodotShape3D * shape0, const Transform3D & wtrs0, float margin0, const GodotShape3D * shape1, const Transform3D & wtrs1, float margin1, const Vector3 & guess, GjkEpa2::sResults & results) Line 899
	at servers\physics_3d\gjk_epa.cpp(899)
godot.windows.editor.dev.x86_64.exe!gjk_epa_calculate_distance(const GodotShape3D * p_shape_A, const Transform3D & p_transform_A, const GodotShape3D * p_shape_B, const Transform3D & p_transform_B, Vector3 & r_result_A, Vector3 & r_result_B) Line 999
	at servers\physics_3d\gjk_epa.cpp(999)
godot.windows.editor.dev.x86_64.exe!GodotCollisionSolver3D::solve_distance(const GodotShape3D * p_shape_A, const Transform3D & p_transform_A, const GodotShape3D * p_shape_B, const Transform3D & p_transform_B, Vector3 & r_point_A, Vector3 & r_point_B, const AABB & p_concave_hint, Vector3 * r_sep_axis) Line 589
	at servers\physics_3d\godot_collision_solver_3d.cpp(589)
godot.windows.editor.dev.x86_64.exe!GodotPhysicsDirectSpaceState3D::cast_motion(const PhysicsDirectSpaceState3D::ShapeParameters & p_parameters, float & p_closest_safe, float & p_closest_unsafe, PhysicsDirectSpaceState3D::ShapeRestInfo * r_info) Line 304
	at servers\physics_3d\godot_space_3d.cpp(304)
godot.windows.editor.dev.x86_64.exe!SpringArm3D::process_spring() Line 164
	at scene\3d\physics\spring_arm_3d.cpp(164)
godot.windows.editor.dev.x86_64.exe!SpringArm3D::_notification(int p_what) Line 54
	at scene\3d\physics\spring_arm_3d.cpp(54)
godot.windows.editor.dev.x86_64.exe!SpringArm3D::_notificationv(int p_notification, bool p_reversed) Line 37
	at scene\3d\physics\spring_arm_3d.h(37)
godot.windows.editor.dev.x86_64.exe!Object::notification(int p_notification, bool p_reversed) Line 906
	at core\object\object.cpp(906)
godot.windows.editor.dev.x86_64.exe!SceneTree::_process_group(SceneTree::ProcessGroup * p_group, bool p_physics) Line 954
	at scene\main\scene_tree.cpp(954)
godot.windows.editor.dev.x86_64.exe!SceneTree::_process(bool p_physics) Line 1042
	at scene\main\scene_tree.cpp(1042)
godot.windows.editor.dev.x86_64.exe!SceneTree::physics_process(double p_time) Line 491
	at scene\main\scene_tree.cpp(491)
godot.windows.editor.dev.x86_64.exe!Main::iteration() Line 4057
	at main\main.cpp(4057)
godot.windows.editor.dev.x86_64.exe!OS_Windows::run() Line 1686
	at platform\windows\os_windows.cpp(1686)
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 181
	at platform\windows\godot_windows.cpp(181)
godot.windows.editor.dev.x86_64.exe!_main() Line 206
	at platform\windows\godot_windows.cpp(206)
godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 220
	at platform\windows\godot_windows.cpp(220)
godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 234
	at platform\windows\godot_windows.cpp(234)
```


### Minimal reproduction project (MRP)

[crash.zip](https://github.com/user-attachments/files/15755041/crash.zip)