You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SIGSEGV in AHashMap::_lookup_pos_with_hash on deep inheritance chains containing an abstract class after commit 2fd41b7 #1862
After commit 2fd41b7 (“Replace unordered_map with AHashMap”), a SIGSEGV caused by a null HashMapData pointer inside AHashMap::_lookup_pos_with_hash() can occur when:
A user-defined C++ class hierarchy contains an abstract class,
The inheritance chain is at least three levels deep (concrete → abstract → concrete → concrete).
Steps to reproduce
Create a concrete Godot class.
class MyBaseClass : public Node3D {};
(in xx_register.cpp) GDREGISTER_CLASS(YShipActor);
Derive an abstract class from it.
class AnAbstractClass : public MyBaseClass {void make_some_func = 0;};
(in xx_register.cpp) GDREGISTER_ABSTRACT_CLASS(AnAbstractClass);
Derive a concrete class from the abstract one. (Still works)
class AGoodGenClass : public AnAbstractClass {};
(in xx_register.cpp) GDREGISTER_CLASS(AGoodGenClass);
Add one more concrete level. (Begin having issue)
class BeginBreakClass : public AGoodGenClass {};
(in xx_register.cpp) GDREGISTER_CLASS(BeginBreakClass);
Instantiate and add the last class to the scene tree.
I’m not good at coding, but from what I can see the crash seems to happen while ClassDB is inserting VirtualMethod entries into a global AHashMap.
My guess is that the appearance of an abstract class in the chain either triggers an unexpected array release or lets one thread query the map while another is still inserting.
Sorry my project has grown too tangled for me to strip out the relevant classes and post a privacy-safe minimal repro.
Hi, it's difficult to guess what exactly is happening without a repro project. Could you try to create a reproduction project, given what you assume is the problem (with concrete / abstract classes)? I'm particularly interested in the details, e.g. on which classes you add GDCLASS etc.
Hi, it's difficult to guess what exactly is happening without a repro project. Could you try to create a reproduction project, given what you assume is the problem (with concrete / abstract classes)? I'm particularly interested in the details, e.g. on which classes you add GDCLASS etc.
Hi, it's difficult to guess what exactly is happening without a repro project. Could you try to create a reproduction project, given what you assume is the problem (with concrete / abstract classes)? I'm particularly interested in the details, e.g. on which classes you add GDCLASS etc.
TL;DR – the issue is resolved.
While I wasn’t able to carve out a minimal repro in a couple of hours (the codebase is sprawling and the classes are tangled like last-year’s Christmas lights), I stumbled on a fix: simply commenting out every GDREGISTER_ABSTRACT_CLASS(MyAbstractClasses) in xxx_register.cpp makes the crash disappear. I have no idea what dark magic lives under the hood, but “it works, it works.”
So, rather than registering the full inheritance chain, I find myself only register the concrete leaf classes I actually instantiate (GDREGISTER_CLASS(TheActualWorkingClass)). That’s enough to keep everything running, which means this ticket can be closed.
Still, I’m curious: why did GDREGISTER_ABSTRACT_CLASS suddenly become toxic? Until the latest commit we were on unordered_map, switching to AHashMap seems to have exposed the land-mine. I completely don't have any a bit clue...
Activity
NathonMei commentedon Oct 7, 2025
I’m not good at coding, but from what I can see the crash seems to happen while ClassDB is inserting VirtualMethod entries into a global AHashMap.
My guess is that the appearance of an abstract class in the chain either triggers an unexpected array release or lets one thread query the map while another is still inserting.
Sorry my project has grown too tangled for me to strip out the relevant classes and post a privacy-safe minimal repro.
Ivorforce commentedon Oct 7, 2025
Hi, it's difficult to guess what exactly is happening without a repro project. Could you try to create a reproduction project, given what you assume is the problem (with concrete / abstract classes)? I'm particularly interested in the details, e.g. on which classes you add
GDCLASSetc.NathonMei commentedon Oct 7, 2025
OK I'll give it a shot
NathonMei commentedon Oct 7, 2025
Hi @Ivorforce , thanks for your follow-up.
TL;DR – the issue is resolved.
While I wasn’t able to carve out a minimal repro in a couple of hours (the codebase is sprawling and the classes are tangled like last-year’s Christmas lights), I stumbled on a fix: simply commenting out every
GDREGISTER_ABSTRACT_CLASS(MyAbstractClasses)in xxx_register.cpp makes the crash disappear. I have no idea what dark magic lives under the hood, but “it works, it works.”So, rather than registering the full inheritance chain, I find myself only register the concrete leaf classes I actually instantiate (
GDREGISTER_CLASS(TheActualWorkingClass)). That’s enough to keep everything running, which means this ticket can be closed.Still, I’m curious: why did
GDREGISTER_ABSTRACT_CLASSsuddenly become toxic? Until the latest commit we were onunordered_map, switching toAHashMapseems to have exposed the land-mine. I completely don't have any a bit clue...Bayonetta5 commentedon Nov 17, 2025