godotengine / godotengine/godot

Crash when importing a 3D scene with UV2 unwrap enabled in a double-precision development build

Open
#109,097 3 comments 0 reactions 0 assignees View on GitHub
bug confirmed crash needs testing topic:3d topic:import
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in: 4.5.beta 2d113cc224cb9be07866d003819fcef2226a52ea

### System information

Godot v4.5.beta (2d113cc22) - Fedora Linux 42 (KDE Plasma Desktop Edition) on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 5090 (nvidia; 575.64.03) - AMD Ryzen 9 9950X3D 16-Core Processor (32 threads) - 62.33 GiB memory

### Issue description

Godot crashes when importing a 3D scene with UV2 unwrap enabled in a double-precision development build. Both `precision=double` **and** `dev_build=yes` must be used to reproduce the crash; otherwise, no crash will happen.

The crash doesn't happen if you disable lightmap unwrapping on import by setting the GI mode to **Static** instead of **Static Lightmaps**.

```
ERROR: FATAL: DEV_ASSERT failed "!has(p_key)" is false.
at: insert_new (./core/templates/a_hash_map.h:624)

================================================================
handle_crash: Program crashed with signal 4
Engine version: Godot Engine v4.5.beta.double.custom_build (f0550de51a9913223b574d0e7c6915130d7e2915)
Dumping the backtrace. Please include this when reporting the bug on: https://github.com/godotengine/godot/issues
[1] /lib64/libc.so.6(+0x19c30) [0x7ff511627c30] (??:0)
[2] AHashMap >::insert_new(SurfaceTool::Vertex&, int const&) (/home/hugo/Documents/Git/godotengine/godot/core/templates/a_hash_map.h:624 (discriminator 5))
[3] SurfaceTool::index() (/home/hugo/Documents/Git/godotengine/godot/scene/resources/surface_tool.cpp:762)
[4] ImporterMesh::lightmap_unwrap_cached(Transform3D const&, float, Vector const&, Vector&) (/home/hugo/Documents/Git/godotengine/godot/scene/resources/3d/importer_mesh.cpp:1166)
[5] ResourceImporterScene::_generate_meshes(Node*, Dictionary const&, bool, bool, ResourceImporterScene::LightBakeMode, float, Vector const&, Vector >&) (/home/hugo/Documents/Git/godotengine/godot/editor/import/3d/resource_importer_scene.cpp:2688 (discriminator 3))
[6] ResourceImporterScene::_generate_meshes(Node*, Dictionary const&, bool, bool, ResourceImporterScene::LightBakeMode, float, Vector const&, Vector >&) (/home/hugo/Documents/Git/godotengine/godot/editor/import/3d/resource_importer_scene.cpp:2790 (discriminator 1))
[7] ResourceImporterScene::import(long, String const&, String const&, HashMap, DefaultTypedAllocator > > const&, List*, List*, Variant*) (/home/hugo/Documents/Git/godotengine/godot/editor/import/3d/resource_importer_scene.cpp:3260)
[8] EditorFileSystem::_reimport_file(String const&, HashMap, DefaultTypedAllocator > > const&, String const&, Variant*, bool) (/home/hugo/Documents/Git/godotengine/godot/editor/file_system/editor_file_system.cpp:2898 (discriminator 1))
[9] EditorFileSystem::reimport_files(Vector const&) (/home/hugo/Documents/Git/godotengine/godot/editor/file_system/editor_file_system.cpp:3313 (discriminator 4))
[10] EditorFileSystem::_update_scan_actions() (/home/hugo/Documents/Git/godotengine/godot/editor/file_system/editor_file_system.cpp:1026)
[11] EditorFileSystem::_notification(int) (/home/hugo/Documents/Git/godotengine/godot/editor/file_system/editor_file_system.cpp:1789)
[12] EditorFileSystem::_notification_forwardv(int) (/home/hugo/Documents/Git/godotengine/godot/editor/file_system/editor_file_system.h:148)
[13] Object::_notification_forward(int) (/home/hugo/Documents/Git/godotengine/godot/core/object/object.cpp:933)
[14] Object::notification(int, bool) (/home/hugo/Documents/Git/godotengine/godot/core/object/object.h:892)
[15] SceneTree::_process_group(SceneTree::ProcessGroup*, bool) (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:1189)
[16] SceneTree::_process(bool) (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:1261 (discriminator 2))
[17] SceneTree::process(double) (/home/hugo/Documents/Git/godotengine/godot/scene/main/scene_tree.cpp:699)
[18] Main::iteration() (/home/hugo/Documents/Git/godotengine/godot/main/main.cpp:4774 (discriminator 3))
[19] OS_LinuxBSD::run() (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/os_linuxbsd.cpp:989 (discriminator 1))
[20] bin/godot.linuxbsd.editor.dev.double.x86_64(main+0x14b) [0x6697171] (/home/hugo/Documents/Git/godotengine/godot/platform/linuxbsd/godot_linuxbsd.cpp:85)
[21] /lib64/libc.so.6(+0x35f5) [0x7ff5116115f5] (??:0)
[22] /lib64/libc.so.6(__libc_start_main+0x88) [0x7ff5116116a8] (??:0)
[23] bin/godot.linuxbsd.editor.dev.double.x86_64(_start+0x25) [0x6696f65] (??:?)
-- END OF C++ BACKTRACE --
================================================================
```

The crash doesn't happen in a single-precision build, or if `precision=double` is used without `dev_build=yes`.

PS: I noticed the unwrap cache files are different for single-precision and double-precision builds. Is that avoidable somehow? This causes spurious VCS diffs when switching back and forth between single and double precision builds. MD5 checksums for each unwrap cache file:

```
960927448fb7bd11782c0d237843a05e food_apple_01_1k.gltf.unwrap_cache (imported in single-precision build)
901ebae318f79252126f2bce83b5779a food_apple_01_1k.gltf.unwrap_cache.double (imported in double-precision build)
```

### Steps to reproduce

- Import the minimal reproduction project in a `precision=double dev_build=yes` build.

### Minimal reproduction project (MRP)

[test_project.zip](https://github.com/user-attachments/files/21497706/test_project.zip)

Contributor guide

Open the contributing guide

Research direction

Reproduce the import with the supplied test_project.zip using a precision=double, dev_build=yes build. Trace the backtrace through scene/resources/surface_tool.cpp, scene/resources/3d/importer_mesh.cpp, and editor/import/3d/resource_importer_scene.cpp, starting at SurfaceTool::index() and ImporterMesh::lightmap_unwrap_cached(). Done means the 3D scene imports with UV2 lightmap unwrapping without the DEV_ASSERT crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.