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

Use image index instead of texture index for source_images #80314

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

lyuma
Copy link
Contributor

@lyuma lyuma commented Aug 5, 2023

Godot was indexing into the images array using p_texture (which is meant for the textures array, not images.)

Fixes #80316
We wanted to remove or clean up source_images, but until we decide, it is still worth fixing this bug.

Total basis file slices: 11
Slice: 0, alpha: 0, orig width/height: 512x1024, width/height: 512x1024, first_block: 0, image_index: 0, mip_level: 0, iframe: 0
Slice: 1, alpha: 0, orig width/height: 256x512, width/height: 256x512, first_block: 32768, image_index: 0, mip_level: 1, iframe: 0
Slice: 2, alpha: 0, orig width/height: 128x256, width/height: 128x256, first_block: 40960, image_index: 0, mip_level: 2, iframe: 0
Slice: 3, alpha: 0, orig width/height: 64x128, width/height: 64x128, first_block: 43008, image_index: 0, mip_level: 3, iframe: 0
Slice: 4, alpha: 0, orig width/height: 32x64, width/height: 32x64, first_block: 43520, image_index: 0, mip_level: 4, iframe: 0
Slice: 5, alpha: 0, orig width/height: 16x32, width/height: 16x32, first_block: 43648, image_index: 0, mip_level: 5, iframe: 0
Slice: 6, alpha: 0, orig width/height: 8x16, width/height: 8x16, first_block: 43680, image_index: 0, mip_level: 6, iframe: 0
Slice: 7, alpha: 0, orig width/height: 4x8, width/height: 4x8, first_block: 43688, image_index: 0, mip_level: 7, iframe: 0
Slice: 8, alpha: 0, orig width/height: 2x4, width/height: 4x4, first_block: 43690, image_index: 0, mip_level: 8, iframe: 0
Slice: 9, alpha: 0, orig width/height: 1x2, width/height: 4x4, first_block: 43691, image_index: 0, mip_level: 9, iframe: 0
Slice: 10, alpha: 0, orig width/height: 1x1, width/height: 4x4, first_block: 43692, image_index: 0, mip_level: 10, iframe: 0
ERROR: FATAL: Index p_index = 42 is out of bounds (size() = 42).
   at: CowData<class Ref<class Image> >::get (S:\repo\godot-fire\core/templates/cowdata.h:155)

================================================================
CrashHandlerException: Program crashed
Engine version: Godot Engine v4.2.dev.custom_build (85ff82196504f013409f94b89708758e13cc4076)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[0] GLTFDocument::_get_texture (S:\repo\godot-fire\modules\gltf\gltf_document.cpp:3393)
[1] GLTFDocument::_parse_materials (S:\repo\godot-fire\modules\gltf\gltf_document.cpp:3932)
[2] GLTFDocument::_parse_gltf_state (S:\repo\godot-fire\modules\gltf\gltf_document.cpp:7390)
[3] GLTFDocument::_parse (S:\repo\godot-fire\modules\gltf\gltf_document.cpp:7026)
[4] GLTFDocument::append_from_file (S:\repo\godot-fire\modules\gltf\gltf_document.cpp:7454)
[5] call_with_variant_args_ret_helper<GLTFDocument,enum Error,String,Ref<GLTFState>,unsigned int,String,0,1,2,3> (S:\repo\godot-fire\core\variant\binder_common.h:755)
[6] call_with_variant_args_ret_dv<GLTFDocument,enum Error,String,Ref<GLTFState>,unsigned int,String> (S:\repo\godot-fire\core\variant\binder_common.h:534)
[7] MethodBindTR<GLTFDocument,enum Error,String,Ref<GLTFState>,unsigned int,String>::call (S:\repo\godot-fire\core\object\method_bind.h:494)
[8] GDScriptFunction::call (S:\repo\godot-fire\modules\gdscript\gdscript_vm.cpp:1779)
[9] GDScriptInstance::callp (S:\repo\godot-fire\modules\gdscript\gdscript.cpp:1892)
[10] Object::callp (S:\repo\godot-fire\core\object\object.cpp:719)
[11] Variant::callp (S:\repo\godot-fire\core\variant\variant_call.cpp:1174)
[12] GDScriptFunction::call (S:\repo\godot-fire\modules\gdscript\gdscript_vm.cpp:1661)
[13] GDScriptLambdaSelfCallable::call (S:\repo\godot-fire\modules\gdscript\gdscript_lambda_callable.cpp:155)
[14] Callable::callp (S:\repo\godot-fire\core\variant\callable.cpp:51)
[15] Object::emit_signalp (S:\repo\godot-fire\core\object\object.cpp:1073)
[16] Node::emit_signalp (S:\repo\godot-fire\scene\main\node.cpp:3571)
[17] Window::_window_drop_files (S:\repo\godot-fire\scene\main\window.cpp:1483)
[18] CallableCustomMethodPointer<Window,Vector<String> const &>::call (S:\repo\godot-fire\core\object\callable_method_pointer.h:104)
[19] Callable::callp (S:\repo\godot-fire\core\variant\callable.cpp:51)
[20] DisplayServerWindows::WndProc (S:\repo\godot-fire\platform\windows\display_server_windows.cpp:3881)
[21] WndProc (S:\repo\godot-fire\platform\windows\display_server_windows.cpp:3901)
[22] <couldn't map PC to fn name>
[23] <couldn't map PC to fn name>
[24] <couldn't map PC to fn name>
[25] <couldn't map PC to fn name>
[26] <couldn't map PC to fn name>
[27] DisplayServerWindows::process_events (S:\repo\godot-fire\platform\windows\display_server_windows.cpp:2290)
[28] OS_Windows::run (S:\repo\godot-fire\platform\windows\os_windows.cpp:1479)
[29] widechar_main (S:\repo\godot-fire\platform\windows\godot_windows.cpp:182)
[30] _main (S:\repo\godot-fire\platform\windows\godot_windows.cpp:206)
[31] main (S:\repo\godot-fire\platform\windows\godot_windows.cpp:226)
[32] __scrt_common_main_seh (D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[33] <couldn't map PC to fn name>
-- END OF BACKTRACE --
================================================================

repro steps: godot-vrm project, load_at_runtime_scene.tscn, drag in this VRM file: https://github.com/godotengine/godot/files/12268455/47999701980962516models1854603302827712615.zip

@aaronfranke aaronfranke added this to the 4.2 milestone Aug 6, 2023
@akien-mga akien-mga added bug cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Aug 7, 2023
@akien-mga akien-mga changed the title Use image index instead of texture index for source_images Use image index instead of texture index for source_images Aug 7, 2023
@akien-mga akien-mga merged commit 0422e9e into godotengine:master Aug 7, 2023
@akien-mga
Copy link
Member

Thanks!

@YuriSizov YuriSizov removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Sep 20, 2023
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.1.2.

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

Successfully merging this pull request may close these issues.

gltf: basis universal crash due OOB index into source_images using texture index
5 participants