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

Racecondition in ResourceLoader::_thread_load_function(void *p_userdata) #95616

Closed
0x0ACB opened this issue Aug 16, 2024 · 2 comments · Fixed by #94169
Closed

Racecondition in ResourceLoader::_thread_load_function(void *p_userdata) #95616

0x0ACB opened this issue Aug 16, 2024 · 2 comments · Fixed by #94169

Comments

@0x0ACB
Copy link
Contributor

0x0ACB commented Aug 16, 2024

Tested versions

4.3-editor

System information

Windows 10

Issue description

With commit 5640e8a the thread_load_mutex is unlocked after status is set to THREAD_LOAD_LOADED. However the code that is following that is still accessing the resource property. If a different thread calls ResourceLoader::load_threaded_get during that time resource will be set to nullptr in

memdelete(load_token);

Steps to reproduce

ResourceLoader::load_threaded_request(m_path, "", false);
....
const auto res = ResourceLoader::load_threaded_get_status(m_path);
if (res == ResourceLoader::THREAD_LOAD_LOADED)
{
    m_resource = ResourceLoader::load_threaded_get(m_path);
    finished();
    return true;
}
if (res != ResourceLoader::THREAD_LOAD_IN_PROGRESS)
{
    // need to remove the load task
    m_resource = ResourceLoader::load_threaded_get(m_path);
    m_error = String("Error loading resource {0}: {1}").format(varray(m_path, res));
    finished();
    return true;
}

Minimal reproduction project (MRP)

@Chaosus
Copy link
Member

Chaosus commented Aug 16, 2024

cc @RandomShaper

@RandomShaper
Copy link
Member

Fixed by #94169.

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.

4 participants