Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Hot reload decrements refcounted objects refcount, causing a crash.

Open
#2,059 4 comments 0 reactions 0 assignees View on GitHub

@agoaj is already working on this.

Since Oct 4, 2026.

  • #2060 by @agoaj — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
50/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp, godot
Domain
game-dev

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from godotengine/godot-cpp

All issues in godotengine/godot-cpp

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.