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

"Attempting to use an uninitialized RID" error is printed when opening the editor #97694

Closed
Calinou opened this issue Oct 1, 2024 · 4 comments · Fixed by #98451
Closed

"Attempting to use an uninitialized RID" error is printed when opening the editor #97694

Calinou opened this issue Oct 1, 2024 · 4 comments · Fixed by #98451

Comments

@Calinou
Copy link
Member

Calinou commented Oct 1, 2024

Tested versions

  • Reproducible in: 4.4.dev e3213aa
  • Not reproducible in: 4.3.stable, 4.4.dev1, 4.4.dev2

System information

Godot v4.4.dev (e3213aa) - Fedora Linux 40 (KDE Plasma) on X11 - X11 display driver, Multi-window, 1 monitor - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (nvidia; 560.35.03) - 13th Gen Intel(R) Core(TM) i9-13900K (32 threads)

Issue description

"Attempting to use an uninitialized RID" error is printed when opening the editor.


ERROR: Attempting to use an uninitialized RID
   at: get_or_null (./core/templates/rid_owner.h:199)
ERROR: Parameter "t" is null.
   at: texture_free (./servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:726)

I bisected the regression from #96982. cc @dsnopek

According to @stuartcarnie, the issue comes from here:

image

Steps to reproduce

  • Open the editor and look at the Output panel or terminal output.

Minimal reproduction project (MRP)

https://github.com/godotengine/godot-demo-projects/tree/master/3d/truck_town (this should be reproducible on an empty project, but I used Truck Town just in case)

@akien-mga
Copy link
Member

Confirmed, also on Linux (Fedora 40).

@akien-mga akien-mga added this to the 4.4 milestone Oct 1, 2024
@akien-mga akien-mga moved this from Unassessed to Bad in 4.x Release Blockers Oct 1, 2024
@AThousandShips
Copy link
Member

Encountered this on Windows as well

@darksylinc
Copy link
Contributor

Full callstack:

1  RID_Alloc<RendererRD::TextureStorage::Texture, true>::get_or_null rid_owner.h                  196  0x55555e92a2db 
2  RID_Owner<RendererRD::TextureStorage::Texture, true>::get_or_null rid_owner.h                  448  0x55555e92a08f 
3  RendererRD::TextureStorage::texture_free                          texture_storage.cpp          719  0x55555ea66eab 
4  RendererRD::TextureStorage::free                                  texture_storage.cpp          548  0x55555ea6632c 
5  RendererRD::Utilities::free                                       utilities.cpp                100  0x55555ea84040 
6  RenderingServerDefault::_free                                     rendering_server_default.cpp 51   0x55555e7b9215 
7  RenderingServerDefault::free                                      rendering_server_default.h   1113 0x55555e7da553 
8  ExternalTexture::~ExternalTexture                                 external_texture.cpp         87   0x55555dba9dc1 
9  memdelete<Object>                                                 memory.h                     140  0x55555aa6ec0f 
10 ClassDB::class_get_default_property_value                         class_db.cpp                 2148 0x55555f371661 
11 get_documentation_default_value                                   doc_tools.cpp                391  0x55555bd304c6 
12 DocTools::generate                                                doc_tools.cpp                546  0x55555bd2cc45 
13 EditorHelp::generate_doc                                          editor_help.cpp              2996 0x55555be52d57 
14 call_with_variant_args_static<bool, 0ul>                          binder_common.h              778  0x55555be728e3 
15 call_with_variant_args_static<bool>                               binder_common.h              847  0x55555be72898 
16 CallableCustomStaticMethodPointer<void, bool>::call               callable_method_pointer.h    251  0x55555be727a3 
17 Callable::callp                                                   callable.cpp                 57   0x55555efe4328 
18 CallQueue::_call_function                                         message_queue.cpp            220  0x55555f3815c9 
19 CallQueue::flush                                                  message_queue.cpp            268  0x55555f3819e0 
20 SceneTree::physics_process                                        scene_tree.cpp               546  0x55555cee0e36 
21 Main::iteration                                                   main.cpp                     4354 0x55555aa6b57d 
22 OS_LinuxBSD::run                                                  os_linuxbsd.cpp              962  0x55555a9a9331 
23 main                                                              godot_linuxbsd.cpp           85   0x55555a9a0abe 
ERROR: Attempting to use an uninitialized RID
   at: get_or_null (./core/templates/rid_owner.h:196)

ERROR: Parameter "t" is null.
   at: texture_free (servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:720)

This error looks like a race condition because it doesn't happen always.

A quick analysis shows that it is possible for ExternalTexture::ExternalTexture (I've not confirmed if this is what's happening) to call texture_external_create() from a worker thread, which will allocate, but not initialize, the RID.

The RID initialization will be queued.

My guess is that ExternalTexture::~ExternalTexture was called before RID initialization; which caused the error.

@darksylinc
Copy link
Contributor

If we look at the creation function (FUNCRIDTEX3() it boils down to (simplified):

RID ret = RSG::texture_storage->texture_allocate();
if( we_are_in_main_thread )
{
    RSG::texture_storage->texture_external_initialize(ret, p1, p2, p3);
}
else
{
    command_queue.push(RSG::texture_storage, &RendererTextureStorage::texture_external_initialize, ret, p1, p2, p3);
}
return ret;

Now the problem is that doing:

RID ret = RSG::texture_storage->texture_allocate();
RenderingServer::get_singleton()->free(ret);

Will trigger the error because texture_external_initialize was never called.

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

Successfully merging a pull request may close this issue.

4 participants