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

Unhandled C++ exception in scriptContentAvilable when changing domains #1036

Closed
ksuprynowicz opened this issue Jun 17, 2024 · 1 comment · Fixed by #1037
Closed

Unhandled C++ exception in scriptContentAvilable when changing domains #1036

ksuprynowicz opened this issue Jun 17, 2024 · 1 comment · Fixed by #1037
Labels
bug Something isn't working

Comments

@ksuprynowicz
Copy link
Member

It happens when script loads after script engine has already been deleted:

terminate called after throwing an instance of 'std::bad_weak_ptr'
  what():  bad_weak_ptr

Backtrace:

__pthread_kill_implementation 0x00007ffff04a816c
operator() ScriptManager.cpp:2057
ScriptCache::scriptContentAvailable ScriptCache.cpp:215
operator() ScriptCache.cpp:128
Application::notify Application.cpp:4292
main main.cpp:776

Source code:

            std::shared_ptr<ScriptManager> strongRef(weakRef);
            if (!strongRef) {
                qCWarning(scriptengine) << "loadEntityScript.contentAvailable -- ScriptManager was deleted during getScriptContents!!";
                return;
@ksuprynowicz
Copy link
Member Author

The issue in the code is that if weakRef is not valid, std::shared_ptr constructor throws an exception instead of making a null shared pointer like our code expects. Using lock() method instead will fix this. We should audit code and find all such occurences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant