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

Editor crashes in RenderingServer::fix_surface_compatibility with mesh reporting 0 vertex count #84997

Closed
KnightNine opened this issue Nov 17, 2023 · 8 comments · Fixed by #85138

Comments

@KnightNine
Copy link

KnightNine commented Nov 17, 2023

Godot version

v4.2.beta.custom_build [575a5c8]

System information

Windows 10

Issue description

After syncing my fork with the master branch, the editor crashes (along with the console window) when running one of my projects in particular. It works fine with other projects.

I get these errors and warnings below in the command prompt (when starting the engine it with --verbose) before it crashes but nothing after or during the crash:

WARNING: GENERAL - Message Id Number: 0 | Message Id Name: Loader Message
        windows_read_data_files_in_registry: Registry lookup failed to get layer manifest files.
        Objects - 1
                Object[0] - VK_OBJECT_TYPE_INSTANCE, Handle 1939231463136
     at: VulkanContext::_debug_messenger_callback (drivers\vulkan\vulkan_context.cpp:264)
ERROR: Viewport Texture must be set to use it.
   at: ViewportTexture::get_height (scene\main\viewport.cpp:137)
ERROR: Viewport Texture must be set to use it.
   at: ViewportTexture::get_width (scene\main\viewport.cpp:127)
WARNING: Mesh uses old surface format, which is deprecated (and loads slower). Consider re-importing or re-saving the scene. Path: ""
     at: (scene\resources\mesh.cpp:1335)
Mesh format pre-conversion: 97559
Mesh format post-conversion: 34359742487
Mesh format pre-conversion: 97559
Mesh format post-conversion: 34359742487
ERROR: Viewport Texture must be set to use it.
   at: ViewportTexture::get_height (scene\main\viewport.cpp:137)
ERROR: Viewport Texture must be set to use it.
   at: ViewportTexture::get_width (scene\main\viewport.cpp:127)
Mesh format pre-conversion: 97559
Mesh format post-conversion: 34359742487
ERROR: Viewport Texture must be set to use it.
   at: ViewportTexture::get_height (scene\main\viewport.cpp:137)
ERROR: Viewport Texture must be set to use it.
   at: ViewportTexture::get_width (scene\main\viewport.cpp:127)
#crash here

Is there a way to debug this without randomly deleting files from my project (a copy of it) to narrow down on what could be causing it?
halp pls!

Steps to reproduce

I can't seem to diagnose the source of the problem to provide steps to reproduce with no info about the cause of the crash.

Minimal reproduction project

N/A

@akien-mga
Copy link
Member

If you compile Godot with scons dev_build=yes, you should be able to get proper debug information the crash, either in the terminal (if our crash handler works) or in the Visual Studio debugger.

You may need to throw in windows_subsystem=console as Windows is a bit weird around its handling of GUI apps and might be silencing console output.

@KnightNine
Copy link
Author

KnightNine commented Nov 18, 2023

@akien-mga
here is the crash using the Visual Studio Debugger:

Unhandled exception at 0x03A851C4 in godot.windows.editor.dev.x86_32.exe: 0xC0000094: Integer division by zero.

the code in question: int stride = p_surface.vertex_data.size() / p_surface.vertex_count;

at line 2167 of rendering_server.cpp

and here is the call stack:

>	godot.windows.editor.dev.x86_32.exe!RenderingServer::fix_surface_compatibility(RenderingServer::SurfaceData & p_surface, const String & p_path) Line 2167	C++
 	godot.windows.editor.dev.x86_32.exe!ArrayMesh::_set_surfaces(const Array & p_surfaces) Line 1643	C++
 	godot.windows.editor.dev.x86_32.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_32.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 450	C++
 	godot.windows.editor.dev.x86_32.exe!MethodBindT<ArrayMesh,Array const &>::call(Object * p_object, const Variant * * p_args, int p_arg_count, Callable::CallError & r_error) Line 333	C++
 	godot.windows.editor.dev.x86_32.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_32.exe!Object::set(const StringName & p_name, const Variant & p_value, bool * r_valid) Line 257	C++
 	godot.windows.editor.dev.x86_32.exe!ResourceLoaderText::load() Line 750	C++
 	godot.windows.editor.dev.x86_32.exe!ResourceFormatLoaderText::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 1653	C++
 	godot.windows.editor.dev.x86_32.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_32.exe!ResourceLoader::_thread_load_function(void * p_userdata) Line 319	C++
 	godot.windows.editor.dev.x86_32.exe!ResourceLoader::_load_start(const String & p_path, const String & p_type_hint, ResourceLoader::LoadThreadMode p_thread_mode, ResourceFormatLoader::CacheMode p_cache_mode) Line 500	C++
 	godot.windows.editor.dev.x86_32.exe!ResourceLoader::load(const String & p_path, const String & p_type_hint, ResourceFormatLoader::CacheMode p_cache_mode, Error * r_error) Line 417	C++
 	godot.windows.editor.dev.x86_32.exe!EditorResourcePreviewGenerator::generate_from_path(const String & p_path, const Vector2 & p_size, Dictionary & p_metadata) Line 68	C++
 	godot.windows.editor.dev.x86_32.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_32.exe!EditorResourcePreview::_iterate() Line 313	C++
 	godot.windows.editor.dev.x86_32.exe!EditorResourcePreview::_thread() Line 338	C++
 	godot.windows.editor.dev.x86_32.exe!EditorResourcePreview::_thread_func(void * ud) Line 103	C++
 	godot.windows.editor.dev.x86_32.exe!Thread::callback(unsigned __int64 p_caller_id, const Thread::Settings & p_settings, void(*)(void *) p_callback, void * p_userdata) Line 61	C++
 	godot.windows.editor.dev.x86_32.exe!std::invoke<void (__cdecl*)(unsigned __int64,Thread::Settings const &,void (__cdecl*)(void *),void *),unsigned __int64,Thread::Settings,void (__cdecl*)(void *),void *>(void(*)(unsigned __int64, const Thread::Settings &, void(*)(void *), void *) && _Obj, unsigned __int64 && _Arg1, Thread::Settings && <_Args2_0>, void(*)(void *) && <_Args2_1>, void * && <_Args2_2>) Line 1572	C++
 	godot.windows.editor.dev.x86_32.exe!std::thread::_Invoke<std::tuple<void (__cdecl*)(unsigned __int64,Thread::Settings const &,void (__cdecl*)(void *),void *),unsigned __int64,Thread::Settings,void (__cdecl*)(void *),void *>,0,1,2,3,4>(void * _RawVals) Line 55	C++
 	godot.windows.editor.dev.x86_32.exe!thread_start<unsigned int (__stdcall*)(void *),1>(void * const parameter) Line 97	C++
 	kernel32.dll!763afcc9()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!77077c6e()	Unknown
 	ntdll.dll!77077c3e()	Unknown

Could it be some sort of mesh in my project that's causing the editor to crash? How can I identify which one using this?

@KnightNine
Copy link
Author

KnightNine commented Nov 18, 2023

what I can understand about it is that fix_surface_compatibility() cannot handle an empty ArrayMesh with the old surface version.
since there's no vertex data there's nothing to convert.

Will adding ze if (p_surface.vertex_count > 0) { before all of the conversions to prevent this from happening bork my project or work completely fine?

//Drumroll....//

NO! it crashed again!:
borked


I do have these errors upon opening my project in my last working version of the engine:

old errors

that Mesh uses old surface format, which is deprecated (and loads slower). Consider re-importing or re-saving the scene. Path: "" warning is concerning because it lacks a path to the scene in question.

@akien-mga akien-mga added this to the 4.2 milestone Nov 18, 2023
@akien-mga akien-mga changed the title Editor crashes without error upon opening my project. Editor crashes in RenderingServer::fix_surface_compatibility with mesh reporting 0 vertex count Nov 18, 2023
@akien-mga
Copy link
Member

If you can get it to crash with the debugger connected, and inspect one of the frames where a p_path is used as argument, its value might be the path to the scene that includes this invalid mesh.

@KnightNine
Copy link
Author

Okay I found the forbidden mesh that was probably ruined by the 3.5 -> 4.0 import process:
Mesh-Point.zip

After deleting it from my project, the project now works in the version of the engine that isn't compiled with dev_build=yes!

It however still seems to crash in text_server_adv.cpp when run through VS debugging with this error.

Exception thrown at 0x00D016B1 in godot.windows.editor.dev.x86_32.exe: 0xC0000005: Access violation writing location 0x00000000.

at line 5866: gl = Glyph();

callstack:

>	godot.windows.editor.dev.x86_32.exe!TextServerAdvanced::_shape_run(TextServerAdvanced::ShapedTextDataAdvanced * p_sd, __int64 p_start, __int64 p_end, hb_script_t p_script, hb_direction_t p_direction, TypedArray<RID> p_fonts, __int64 p_span, __int64 p_fb_index, __int64 p_prev_start, __int64 p_prev_end) Line 5866	C++
 	godot.windows.editor.dev.x86_32.exe!TextServerAdvanced::_shaped_text_shape(const RID & p_shaped) Line 6183	C++
 	godot.windows.editor.dev.x86_32.exe!TextServerAdvanced::_shaped_text_tab_align(const RID & p_shaped, const Vector<float> & p_tab_stops) Line 4755	C++
 	godot.windows.editor.dev.x86_32.exe!TextServerAdvanced::shaped_text_tab_align(const RID & arg1, const Vector<float> & arg2) Line 926	C++
 	godot.windows.editor.dev.x86_32.exe!TextParagraph::_shape_lines() Line 156	C++
 	godot.windows.editor.dev.x86_32.exe!TextParagraph::get_line_count() Line 547	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::Text::get_line_wrap_amount(int p_line) Line 126	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::Text::invalidate_cache(int p_line, int p_column, bool p_text_changed, const String & p_ime_text, const Array & p_bidi_override) Line 226	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::Text::insert(int p_at, const Vector<String> & p_text, const Vector<Array> & p_bidi_override) Line 354	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::_base_insert_text(int p_line, int p_char, const String & p_text, int & r_end_line, int & r_end_column) Line 7798	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::_insert_text(int p_line, int p_char, const String & p_text, int * r_end_line, int * r_end_char) Line 7665	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::insert_text_at_caret(const String & p_text, int p_caret) Line 3556	C++
 	godot.windows.editor.dev.x86_32.exe!TextEdit::set_text(const String & p_text) Line 3395	C++
 	godot.windows.editor.dev.x86_32.exe!TextEditor::set_edited_resource(const Ref<Resource> & p_res) Line 107	C++
 	godot.windows.editor.dev.x86_32.exe!ScriptEditor::edit(const Ref<Resource> & p_resource, int p_line, int p_col, bool p_grab_focus) Line 2402	C++
 	godot.windows.editor.dev.x86_32.exe!ScriptEditor::edit(const Ref<Resource> & p_resource, bool p_grab_focus) Line 514	C++
 	godot.windows.editor.dev.x86_32.exe!ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) Line 3247	C++
 	godot.windows.editor.dev.x86_32.exe!ScriptEditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) Line 4314	C++
 	godot.windows.editor.dev.x86_32.exe!EditorData::set_plugin_window_layout(Ref<ConfigFile> p_layout) Line 945	C++
 	godot.windows.editor.dev.x86_32.exe!EditorNode::_load_editor_layout() Line 5109	C++
 	godot.windows.editor.dev.x86_32.exe!EditorNode::_sources_changed(bool p_exist) Line 1057	C++
 	godot.windows.editor.dev.x86_32.exe!call_with_variant_args_helper<EditorNode,bool,0>(EditorNode * p_instance, void(EditorNode::*)(bool) p_method, const Variant * * p_args, Callable::CallError & r_error, IndexSequence<0> __formal) Line 308	C++
 	godot.windows.editor.dev.x86_32.exe!call_with_variant_args<EditorNode,bool>(EditorNode * p_instance, void(EditorNode::*)(bool) p_method, const Variant * * p_args, int p_argcount, Callable::CallError & r_error) Line 417	C++
 	godot.windows.editor.dev.x86_32.exe!CallableCustomMethodPointer<EditorNode,bool>::call(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 104	C++
 	godot.windows.editor.dev.x86_32.exe!Callable::callp(const Variant * * p_arguments, int p_argcount, Variant & r_return_value, Callable::CallError & r_call_error) Line 58	C++
 	godot.windows.editor.dev.x86_32.exe!Object::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 1128	C++
 	godot.windows.editor.dev.x86_32.exe!Node::emit_signalp(const StringName & p_name, const Variant * * p_args, int p_argcount) Line 3607	C++
 	godot.windows.editor.dev.x86_32.exe!Object::emit_signal<bool>(const StringName & p_name, bool <p_args_0>) Line 922	C++
 	godot.windows.editor.dev.x86_32.exe!EditorFileSystem::_notification(int p_what) Line 1286	C++
 	godot.windows.editor.dev.x86_32.exe!EditorFileSystem::_notificationv(int p_notification, bool p_reversed) Line 146	C++
 	godot.windows.editor.dev.x86_32.exe!Object::notification(int p_notification, bool p_reversed) Line 840	C++
 	godot.windows.editor.dev.x86_32.exe!SceneTree::_process_group(SceneTree::ProcessGroup * p_group, bool p_physics) Line 954	C++
 	godot.windows.editor.dev.x86_32.exe!SceneTree::_process(bool p_physics) Line 1031	C++
 	godot.windows.editor.dev.x86_32.exe!SceneTree::process(double p_time) Line 510	C++
 	godot.windows.editor.dev.x86_32.exe!Main::iteration() Line 3636	C++
 	godot.windows.editor.dev.x86_32.exe!OS_Windows::run() Line 1474	C++
 	godot.windows.editor.dev.x86_32.exe!widechar_main(int argc, wchar_t * * argv) Line 182	C++
 	godot.windows.editor.dev.x86_32.exe!_main() Line 204	C++
 	godot.windows.editor.dev.x86_32.exe!main(int argc, char * * argv) Line 218	C++
 	godot.windows.editor.dev.x86_32.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 231	C++
 	[Inline Frame] godot.windows.editor.dev.x86_32.exe!invoke_main() Line 102	C++
 	godot.windows.editor.dev.x86_32.exe!__scrt_common_main_seh() Line 288	C++
 	kernel32.dll!763afcc9()	Unknown
 	[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]	
 	ntdll.dll!77077c6e()	Unknown
 	ntdll.dll!77077c3e()	Unknown

not sure what that's about...

either way this issue is resolved.

@YuriSizov
Copy link
Contributor

YuriSizov commented Nov 20, 2023

Okay I found the forbidden mesh that was probably ruined by the 3.5 -> 4.0 import process:
Mesh-Point.zip

Note that this file is not enough to trigger the crash, as far as I can tell. If you add this mesh to an empty project by its lonesome, it just spews errors about not being imported correctly and missing materials.

Edit: Okay, removing the material reference from the file manually does it, I can trigger the crash now.

@YuriSizov
Copy link
Contributor

It however still seems to crash in text_server_adv.cpp when run through VS debugging with this error.

This doesn't seem to be related. Please make sure to open a new issue with details about this problem.

@KnightNine
Copy link
Author

@YuriSizov

It however still seems to crash in text_server_adv.cpp when run through VS debugging with this error.

This doesn't seem to be related. Please make sure to open a new issue with details about this problem.

Decided to come back to this, but I can no longer replicate that error, it seems to be dependent on a certain scene being open in the editor before testing it within VS. and I don't know which scene was the cause of that specific issue.
anyways here are the other issues :
#85451

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

Successfully merging a pull request may close this issue.

3 participants