godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.84k stars 21.13k forks source link

Crash during startup editing a project #85201

Closed Malcolmnixon closed 11 months ago

Malcolmnixon commented 11 months ago

Godot version

7022271291a3d2a9cbd6a223d22a29fd775dfc5d

System information

Windows 11, gl_compatibility, NVidia RTX 3070 TI

Issue description

Crash doing a memcpy to null doing the surface upgrade. The code in question is:

    // Copy over all data needed for rendering.
    glBindBuffer(GL_ARRAY_BUFFER, state.canvas_instance_data_buffers[state.current_data_buffer_index].instance_buffers[state.current_instance_buffer_index]);
#ifdef WEB_ENABLED
    glBufferSubData(GL_ARRAY_BUFFER, state.last_item_index * sizeof(InstanceData), sizeof(InstanceData) * index, state.instance_data_array);
#else
    // On Desktop and mobile we map the memory without synchronizing for maximum speed.
    void *buffer = glMapBufferRange(GL_ARRAY_BUFFER, state.last_item_index * sizeof(InstanceData), index * sizeof(InstanceData), GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
    memcpy(buffer, state.instance_data_array, index * sizeof(InstanceData));
    glUnmapBuffer(GL_ARRAY_BUFFER);
#endif

The call stack is:

godot.windows.editor.dev.x86_64.exe!memcpy_repmovs() Line 40    Unknown
godot.windows.editor.dev.x86_64.exe!RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_count, const Transform2D & p_canvas_transform_inverse, RendererCanvasRender::Light * p_lights, bool & r_sdf_used, bool p_to_backbuffer) Line 652    C++
godot.windows.editor.dev.x86_64.exe!RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, RendererCanvasRender::Item * p_item_list, const Color & p_modulate, RendererCanvasRender::Light * p_light_list, RendererCanvasRender::Light * p_directional_light_list, const Transform2D & p_canvas_transform, RenderingServer::CanvasItemTextureFilter p_default_filter, RenderingServer::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, bool & r_sdf_used) Line 549  C++
godot.windows.editor.dev.x86_64.exe!RendererCanvasCull::_render_canvas_item_tree(RID p_to_render_target, RendererCanvasCull::Canvas::ChildItem * p_child_items, int p_child_item_count, RendererCanvasCull::Item * p_canvas_item, const Transform2D & p_transform, const Rect2 & p_clip_rect, const Color & p_modulate, RendererCanvasRender::Light * p_lights, RendererCanvasRender::Light * p_directional_lights, RenderingServer::CanvasItemTextureFilter p_default_filter, RenderingServer::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, unsigned int canvas_cull_mask) Line 73  C++
godot.windows.editor.dev.x86_64.exe!RendererCanvasCull::render_canvas(RID p_render_target, RendererCanvasCull::Canvas * p_canvas, const Transform2D & p_transform, RendererCanvasRender::Light * p_lights, RendererCanvasRender::Light * p_directional_lights, const Rect2 & p_clip_rect, RenderingServer::CanvasItemTextureFilter p_default_filter, RenderingServer::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_transforms_to_pixel, bool p_snap_2d_vertices_to_pixel, unsigned int canvas_cull_mask) Line 382   C++
godot.windows.editor.dev.x86_64.exe!RendererViewport::_draw_viewport(RendererViewport::Viewport * p_viewport) Line 590  C++
godot.windows.editor.dev.x86_64.exe!RendererViewport::draw_viewports(bool p_swap_buffers) Line 772  C++
godot.windows.editor.dev.x86_64.exe!RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) Line 92   C++
godot.windows.editor.dev.x86_64.exe!RenderingServerDefault::draw(bool p_swap_buffers, double frame_step) Line 387   C++
godot.windows.editor.dev.x86_64.exe!Main::iteration() Line 3648 C++
godot.windows.editor.dev.x86_64.exe!EditorNode::immediate_confirmation_dialog(const String & p_text, const String & p_ok_text, const String & p_cancel_text, unsigned int p_wrap_width) Line 5579   C++
godot.windows.editor.dev.x86_64.exe!SurfaceUpgradeTool::_show_popup() Line 89   C++
godot.windows.editor.dev.x86_64.exe!SurfaceUpgradeTool::_try_show_popup() Line 75   C++
godot.windows.editor.dev.x86_64.exe!RenderingServer::fix_surface_compatibility(RenderingServer::SurfaceData & p_surface, const String & p_path) Line 2138   C++
godot.windows.editor.dev.x86_64.exe!ArrayMesh::_set_surfaces(const Array & p_surfaces) Line 1643    C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_helper<ArrayMesh,Array const &,0>(ArrayMesh * p_instance, void(ArrayMesh::*)(const Array &) p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<0> __formal) Line 303   C++
godot.windows.editor.dev.x86_64.exe!call_with_variant_args_dv<ArrayMesh,Array const &>(ArrayMesh * p_instance, void(ArrayMesh::*)(const Array &) p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error, const Vector<Variant> & default_values) Line 451    C++
godot.windows.editor.dev.x86_64.exe!MethodBindT<ArrayMesh,Array const &>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Callable::CallError & r_error) Line 337    C++
godot.windows.editor.dev.x86_64.exe!ClassDB::set_property(Object * p_object, const StringName & p_property, const Variant & p_value, bool * r_valid) Line 1235  C++
godot.windows.editor.dev.x86_64.exe!Object::set(const StringName & p_name, const Variant & p_value, bool * r_valid) Line 257    C++
godot.windows.editor.dev.x86_64.exe!ResourceLoaderBinary::load() Line 836   C++
godot.windows.editor.dev.x86_64.exe!ResourceFormatLoaderBinary::load(const String & p_path, const String & p_original_path, Error * r_error, bool p_use_sub_threads, float * r_progress, ResourceFormatLoader::CacheMode p_cache_mode) Line 1198    C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::_load(const String & p_path, const String & p_original_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error, bool p_use_sub_threads, float * r_progress) Line 261    C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::_thread_load_function(void * p_userdata) Line 319   C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::_load_start(const String & p_path, const String & p_type_hint, ResourceLoader::LoadThreadMode p_thread_mode, ResourceFormatLoader::CacheMode p_cache_mode) Line 501 C++
godot.windows.editor.dev.x86_64.exe!ResourceLoader::load(const String & p_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error) Line 418 C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreviewGenerator::generate_from_path(const String & p_path, const Vector2 & p_size, Dictionary & p_metadata) Line 68  C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_generate_preview(Ref<ImageTexture> & r_texture, Ref<ImageTexture> & r_small_texture, const EditorResourcePreview::QueueItem & p_item, const String & cache_base, Dictionary & p_metadata) Line 159  C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_iterate() Line 251  C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_thread() Line 338   C++
godot.windows.editor.dev.x86_64.exe!EditorResourcePreview::_thread_func(void * ud) Line 103 C++
godot.windows.editor.dev.x86_64.exe!Thread::callback(unsigned __int64 p_caller_id, const Thread::Settings & p_settings, void(*)(void *) p_callback, void * p_userdata) Line 63  C++
[External Code] 
godot.windows.editor.dev.x86_64.exe!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97 C++
[External Code] 

Steps to reproduce

There's a demo project at https://github.com/Malcolmnixon/TiltFiveMapTest which produces the problem.

The first time its loaded without a .godot folder there are a bunch of assert failures on in vhacdVolume.h line 365.

Minimal reproduction project

The link in the reproduce steps does it. I'm not sure about making anything smaller as it seems to require special circumstances to occur.

YuriSizov commented 11 months ago

The first time its loaded without a .godot folder there are a bunch of assert failures on in vhacdVolume.h line 365.

Shouldn't this be a separate reported issue? It happens with a couple of assets, are they not valid in some way?

godot.windows.editor.dev.x86_64.exe!common_assert_to_message_box<wchar_t>(const wchar_t * const expression, const wchar_t * const file_name, const unsigned int line_number, void * const return_address) Line 388 (c:\Users\yasch\AppData\Local\Programs\Microsoft VS Code\minkernel\crts\ucrt\src\appcrt\startup\assert.cpp:388)
godot.windows.editor.dev.x86_64.exe!VHACD::Volume::Voxelize<float>(const float * const points, const unsigned int stridePoints, const unsigned int nPoints, const int * const triangles, const unsigned int strideTriangles, const unsigned int nTriangles, const unsigned __int64 dim, const VHACD::Vec3<double> & barycenter, const double[3][3] & rot) Line 365 (c:\Projects\godot-engine\master\thirdparty\vhacd\inc\vhacdVolume.h:365)
godot.windows.editor.dev.x86_64.exe!VHACD::VHACD::VoxelizeMesh<float>(const float * const points, const unsigned int stridePoints, const unsigned int nPoints, const int * const triangles, const unsigned int strideTriangles, const unsigned int nTriangles, const VHACD::IVHACD::Parameters & params) Line 281 (c:\Projects\godot-engine\master\thirdparty\vhacd\inc\vhacdVHACD.h:281)
godot.windows.editor.dev.x86_64.exe!VHACD::VHACD::ComputeACD<float>(const float * const points, const unsigned int nPoints, const unsigned int * const triangles, const unsigned int nTriangles, const VHACD::IVHACD::Parameters & params) Line 328 (c:\Projects\godot-engine\master\thirdparty\vhacd\inc\vhacdVHACD.h:328)
godot.windows.editor.dev.x86_64.exe!VHACD::VHACD::Compute(const float * const points, const unsigned int nPoints, const unsigned int * const triangles, const unsigned int nTriangles, const VHACD::IVHACD::Parameters & params) Line 452 (c:\Projects\godot-engine\master\thirdparty\vhacd\src\VHACD.cpp:452)
godot.windows.editor.dev.x86_64.exe!convex_decompose(const float * p_vertices, int p_vertex_count, const unsigned int * p_triangles, int p_triangle_count, const Ref<MeshConvexDecompositionSettings> & p_settings, Vector<Vector<unsigned int>> * r_convex_indices) Line 57 (c:\Projects\godot-engine\master\modules\vhacd\register_types.cpp:57)
godot.windows.editor.dev.x86_64.exe!ImporterMesh::convex_decompose(const Ref<MeshConvexDecompositionSettings> & p_settings) Line 984 (c:\Projects\godot-engine\master\scene\resources\importer_mesh.cpp:984)
godot.windows.editor.dev.x86_64.exe!ResourceImporterScene::get_collision_shapes<Dictionary>(const Ref<ImporterMesh> & p_mesh, const Dictionary & p_options, float p_applied_root_scale) Line 406 (c:\Projects\godot-engine\master\editor\import\resource_importer_scene.h:406)
godot.windows.editor.dev.x86_64.exe!ResourceImporterScene::_post_fix_node(Node * p_node, Node * p_root, HashMap<Ref<ImporterMesh>,Vector<Ref<Shape3D>>,HashMapHasherDefault,HashMapComparatorDefault<Ref<ImporterMesh>>,DefaultTypedAllocator<HashMapElement<Ref<ImporterMesh>,Vector<Ref<Shape3D>>>>> & collision_map, Pair<Vector<Vector3>,Vector<int>> & r_occluder_arrays, HashSet<Ref<ImporterMesh>,HashMapHasherDefault,HashMapComparatorDefault<Ref<ImporterMesh>>> & r_scanned_meshes, const Dictionary & p_node_data, const Dictionary & p_material_data, const Dictionary & p_animation_data, float p_animation_fps, float p_applied_root_scale) Line 1238 (c:\Projects\godot-engine\master\editor\import\resource_importer_scene.cpp:1238)
godot.windows.editor.dev.x86_64.exe!ResourceImporterScene::_post_fix_node(Node * p_node, Node * p_root, HashMap<Ref<ImporterMesh>,Vector<Ref<Shape3D>>,HashMapHasherDefault,HashMapComparatorDefault<Ref<ImporterMesh>>,DefaultTypedAllocator<HashMapElement<Ref<ImporterMesh>,Vector<Ref<Shape3D>>>>> & collision_map, Pair<Vector<Vector3>,Vector<int>> & r_occluder_arrays, HashSet<Ref<ImporterMesh>,HashMapHasherDefault,HashMapComparatorDefault<Ref<ImporterMesh>>> & r_scanned_meshes, const Dictionary & p_node_data, const Dictionary & p_material_data, const Dictionary & p_animation_data, float p_animation_fps, float p_applied_root_scale) Line 1096 (c:\Projects\godot-engine\master\editor\import\resource_importer_scene.cpp:1096)
godot.windows.editor.dev.x86_64.exe!ResourceImporterScene::import(const String & p_source_file, const String & p_save_path, const HashMap<StringName,Variant,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,Variant>>> & p_options, List<String,DefaultAllocator> * r_platform_variants, List<String,DefaultAllocator> * r_gen_files, Variant * r_metadata) Line 2504 (c:\Projects\godot-engine\master\editor\import\resource_importer_scene.cpp:2504)
godot.windows.editor.dev.x86_64.exe!EditorFileSystem::_reimport_file(const String & p_file, const HashMap<StringName,Variant,HashMapHasherDefault,HashMapComparatorDefault<StringName>,DefaultTypedAllocator<HashMapElement<StringName,Variant>>> & p_custom_options, const String & p_custom_importer, Variant * p_generator_parameters) Line 2048 (c:\Projects\godot-engine\master\editor\editor_file_system.cpp:2048)
godot.windows.editor.dev.x86_64.exe!EditorFileSystem::reimport_files(const Vector<String> & p_files) Line 2315 (c:\Projects\godot-engine\master\editor\editor_file_system.cpp:2315)
godot.windows.editor.dev.x86_64.exe!EditorFileSystem::_update_scan_actions() Line 691 (c:\Projects\godot-engine\master\editor\editor_file_system.cpp:691)
godot.windows.editor.dev.x86_64.exe!EditorFileSystem::_notification(int p_what) Line 1283 (c:\Projects\godot-engine\master\editor\editor_file_system.cpp:1283)
godot.windows.editor.dev.x86_64.exe!EditorFileSystem::_notificationv(int p_notification, bool p_reversed) Line 146 (c:\Projects\godot-engine\master\editor\editor_file_system.h:146)
godot.windows.editor.dev.x86_64.exe!Object::notification(int p_notification, bool p_reversed) Line 840 (c:\Projects\godot-engine\master\core\object\object.cpp:840)
godot.windows.editor.dev.x86_64.exe!SceneTree::_process_group(SceneTree::ProcessGroup * p_group, bool p_physics) Line 954 (c:\Projects\godot-engine\master\scene\main\scene_tree.cpp:954)
godot.windows.editor.dev.x86_64.exe!SceneTree::_process(bool p_physics) Line 1031 (c:\Projects\godot-engine\master\scene\main\scene_tree.cpp:1031)
godot.windows.editor.dev.x86_64.exe!SceneTree::process(double p_time) Line 510 (c:\Projects\godot-engine\master\scene\main\scene_tree.cpp:510)
godot.windows.editor.dev.x86_64.exe!Main::iteration() Line 3636 (c:\Projects\godot-engine\master\main\main.cpp:3636)
godot.windows.editor.dev.x86_64.exe!OS_Windows::run() Line 1474 (c:\Projects\godot-engine\master\platform\windows\os_windows.cpp:1474)
godot.windows.editor.dev.x86_64.exe!widechar_main(int argc, wchar_t * * argv) Line 182 (c:\Projects\godot-engine\master\platform\windows\godot_windows.cpp:182)
godot.windows.editor.dev.x86_64.exe!_main() Line 204 (c:\Projects\godot-engine\master\platform\windows\godot_windows.cpp:204)
godot.windows.editor.dev.x86_64.exe!main(int argc, char * * argv) Line 218 (c:\Projects\godot-engine\master\platform\windows\godot_windows.cpp:218)
godot.windows.editor.dev.x86_64.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 232 (c:\Projects\godot-engine\master\platform\windows\godot_windows.cpp:232)
[Inline Frame] godot.windows.editor.dev.x86_64.exe!invoke_main() Line 102 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:102)
godot.windows.editor.dev.x86_64.exe!__scrt_common_main_seh() Line 288 (d:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ff81140257d() (Unknown Source:0)
ntdll.dll!00007ff81206aa58() (Unknown Source:0)