Hot reload decrements refcounted objects refcount, causing a crash.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 50/100
Research direction
Start with the provided hot-reload-refcount-bug.zip reproduction and run it with the godot-cpp submodule initialized and hot reload enabled through CMake or SCons. Read SafeRefCount::_check_unref_safety and trace what happens to a Ref<> resource with a refcount of 1 during reload. Done means the same reload no longer decrements an already-zero refcount or crashes.
Written by the indexing model from the issue text.
Description
Godot version
4.7.1
godot-cpp version
507ed9d
System information
Windows 11, Kubuntu amd64
Issue description
Hot reloading would cause random crashes. Running a godot debug build it would trigger a crash condition in SafeRefCount::_check_unref_safety with this message:
"Upon a SafeRefCount reaching zero any object whose lifetime is tied to it, as well as the ref count itself, must be destroyed.\n"
"Moreover, to guarantee that, no multiple threads should be racing to do the final unreferencing to zero."
Steps to reproduce
The gist of reproducing the issue is to have a Ref<> to a resource with a refcount of 1. On hot reload this will crash.
The easiest way to set this up was to create a Node in the scene that holds a Ref to a resource. One hot reload should trigger a crash.
Minimal reproduction project
hot-reload-refcount-bug.zip
Extract this zip, init the godot-cpp submodule, run the cmake project or build modules with scons with hot reload enabled.
Open the project in godot.
Make a whitespace change in the extension source, recompile the module.
Return to the opened project in godot to trigger hot reload, it should crash.
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 813
- Avg merge
- 1h 31m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from godotengine/godot-cpp
-
Building gdextensions with lto=full warns about serial compilatonPossibly taken @marcozee03 claimed this 32 days ago. Openenhancement topic:buildsystem
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
godotengine/godot-cpp#2002 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
godotengine/godot-cpp#1969 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
godotengine/godot-cpp#1967 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 50/100
godotengine/godot-cpp#2042 ·
-
bug crash
Difficulty 4/5 3-5 days Newbie friendliness 35/100
godotengine/godot-cpp#2024 · 5 comments ·
All issues in godotengine/godot-cpp
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
EchoTools/nevr-runtime#116 ·
Maintainers usually reply within 1 day
-
code-quality libc++
Difficulty 1/5 Under an hour Newbie friendliness 82/100
llvm/llvm-project#229284 ·
Maintainers usually reply within 1 day
-
test-issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
llvm/offload-test-suite#1557 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
iOS: hidden scale bar invalidates its intrinsic content size on every layout pass of MLNMapViewOpen
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
maplibre/maplibre-native#4723 ·
Maintainers usually reply within 1 day