Skip to content

Fix ClassDB crash caused by HashMap reallocation invalidating parent_ptr#1886

Closed
SiimonDev wants to merge 1 commit into
godotengine:masterfrom
SiimonDev:fix-classdb-realloc-crash
Closed

Fix ClassDB crash caused by HashMap reallocation invalidating parent_ptr#1886
SiimonDev wants to merge 1 commit into
godotengine:masterfrom
SiimonDev:fix-classdb-realloc-crash

Conversation

@SiimonDev

@SiimonDev SiimonDev commented Nov 26, 2025

Copy link
Copy Markdown

Issue:
Currently, ClassInfo stores a parent_ptr that points to the parent class's entry inside the global classes HashMap. However, HashMap stores elements contiguously. When new classes are registered and the map exceeds its capacity, it triggers a resize/reallocation. This moves all existing ClassInfo objects to new memory addresses. Any existing parent_ptr held by child classes becomes a dangling pointer to freed memory. This causes random crashes in get_virtual_func when looking up parent methods, depending on registration order and memory reuse.

Proposed Fix:
Remove parent_ptr and replace it with a dynamic lookup using classes.find(parent_name).

This is the first time doing any kind of pull-requests so if anything looks wrong please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This has been identified as a bug crash regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants