Debugging Rare Freeze in Godot: Engine Detaches from Process

Godot Version

Godot 4.2.2 - Steam Release

Question I have encountered a recurring issue in my project where the game freezes unexpectedly and sporadically. This freeze does not trigger the debugger, making it difficult to pinpoint the cause, as Godot seems to detach from the running game process. Notably, I cannot pause or interact with the process during these instances, which has really made it difficult to find a cause.

The only clue I have comes from a consistent engine error logged each time:

E 0:07:38:0349   remove: Condition "p_elem->_root != this" is true.
<C++ Source> ./core/templates/self_list.h:80 @ remove()

Despite the rarity of this issue, it has persisted throughout the development process. I have used print statements in various areas I suspected might be related to the freeze, aiming to capture any abnormal behavior right before the freeze occurs. However, this method has yet to yield a breakthrough.

Main Questions

  1. Are there specific methods or tools within Godot that might help identify and resolve such freezes?
  2. Can I access any logs that might provide insights into what happens just before everything stops responding?
  3. Any general advice on tackling unresponsive behaviors in Godot would be highly valuable, especially given my limited experience with the engine.

This is only my second project using Godot, and any guidance or suggestions would be greatly appreciated.

You have any for loop or while in your code?

This freeze does not trigger the debugger, making it difficult to pinpoint the cause, as Godot seems to detach from the running game process.

What debugger are you using? For example, with gdb you can do set follow-fork-mode child .

I was just using the built in Godot Debugger, is that something I can configure through that? I honestly don’t know if that uses gdb, or something else.

Sorry, I was assuming you were using a debugger for Godot itself (C++), not a gdscript debugger.

Have you seen this thread? "Condition 'p_elem->_root!=this' is true." errors when adding nodes from a thread · Issue #8691 · godotengine/godot · GitHub

Maybe related to thread unsafe code.

There are a handful, but none that either aren’t iterating through a fixed sized list, or would be running at the time of the crash. Unless better terrain might be causing something to go wrong.

Hmm, I haven’t intentionally been working on different threads, but would it be best practice to set all my add_child() calls to call_deferred? I could see some of my temporary particle spawning lining up with the issue.

The way I solve issues like this is by putting a breakpoint on whatever source file is generating the p_elem->_root != this error. You’ll need to:

  1. Compile Godot in debug mode
  2. Attach a debugger (some IDEs have debugger integration and do this automatically)
  3. Inspect the resulting stackframes/variables.
  4. Identify the offending object by traversing up the call stack.
1 Like

Gotcha this seems like a plan, I’ll try doing this with CLion, was kinda toying with this idea, but it felt too much like nuclear option. But honestly working from a local build of Godot, would probably be better for just identifying more of these issues. I’ll just work from that for a few days until the bug happens again. Thanks for the help!

CLion will automatically breakpoint when the process e.g segfaults (so possibly you dont need to set a breakpoint to catch the game freezing).

1 Like