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

Fix crash in resource load #74166

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,21 @@ Ref<Resource> ResourceLoader::load_threaded_get(const String &p_path, Error *r_e
print_lt("GET: load count: " + itos(thread_loading_count) + " / wait count: " + itos(thread_waiting_count) + " / suspended count: " + itos(thread_suspended_count) + " / active: " + itos(thread_loading_count - thread_suspended_count));
}

bool still_valid = true;
bool was_thread = load_task.thread;
do {
load_task.cond_var->wait(thread_load_lock);
if (!thread_load_tasks.has(local_path)) { //may have been erased during unlock and this was always an invalid call
still_valid = false;
break;
}
} while (load_task.cond_var); // In case of spurious wakeup.

thread_suspended_count--;
if (was_thread) {
thread_suspended_count--;
}

if (!thread_load_tasks.has(local_path)) { //may have been erased during unlock and this was always an invalid call
if (!still_valid) {
if (r_error) {
*r_error = ERR_INVALID_PARAMETER;
}
Expand Down