ObjectDB misses instances: empty --verbose leak list, missing orphan nodes, wrong OBJECT_COUNT
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend, performance
Direzione di ricerca
Start with the ObjectDB slot and block handling in core/object/object.cpp, especially get_object_count(), cleanup(), and debug_objects(). Compare the reported loops and ID construction with the block layout introduced by #1121, then inspect the linked fix for its unit test. Done means the count, orphan listing, leak IDs, and cleanup cover all allocated blocks; the reported reproduction checks should match the fixed results.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tested versions
- Reproducible in: v26.3.stable.official [85e520394]
- Also reproducible in an unmodified local build of the same commit.
- The same code is on
masteranddev. Upstream Godot is not affected: it still uses a single flatobject_slotsarray, while the block layout came with #1121.
System information
Windows 10 Pro 22H2 (build 19045), x86-64. Reproduced headless with the Dummy audio driver, so the GPU and renderer are not involved.
Issue description
Four things that read the ObjectDB report wrong numbers or miss objects:
--verbosedoes not list leaked instances. The engine printsObjectDB instances leaked at exit (run with --verbose for details), but with--verboseit prints only the hint line and noLeaked instance:lines.Node.print_orphan_nodes()andNode.get_orphan_node_ids()miss orphan nodes. In the MRP,get_orphan_node_ids()finds 0 of 3 orphan nodes.Performance.OBJECT_COUNTis wrong. In the MRP it goes from 542 to 518 after creating 1000 objects.- The leak warning can be skipped. It is missed when the leaked objects happen to fill whole blocks exactly. This one comes from the code and was not reproduced.
Cause. Since #1121, ObjectDB stores its slots in growing blocks (blocks[1..block_max], of sizes 128, 256, 512, ...). Free slots are handed out as a stack that runs across the blocks:
block_countis the block that holds the top of that stack, not the number of allocated blocks;slot_countis the position inside that block, not the number of live objects.
Because freed slots are reused, a live object can be in any allocated block, up to block_max.
The older single-array code treated slot_count as the total, and the block code still does in several places. In core/object/object.cpp:
int ObjectDB::get_object_count() {
return slot_count; // Only the slots used in the current block.
}
void ObjectDB::cleanup() {
if (slot_count > 0) { // Skips the warning when the current block is exactly empty.
...
for (uint32_t i = 1; i < block_count; i++) { // Skips block `block_count` and every block above it.
...
uint64_t id = uint64_t(i) | (uint64_t(blocks[i][j].validator) << OBJECTDB_SLOT_MAX_COUNT_BITS) | ...; // Block number and wrong shift, not the slot position.
...
for (uint32_t i = 1; i < block_count; i++) {
memfree(blocks[i]); // Blocks from `block_count` up to `block_max` are never freed.
}
}
debug_objects(), which the orphan-node functions use, has the same i < block_count loop.
At exit, most objects have been freed and few slots are in use, so block_count is usually 1. The listing loop then runs zero times.
Fix available. dominicbytes/redot-engine#11 (single commit 7a2fe51, against 26.3-stable) does four things:
- counts live instances as the full blocks below
block_countplusslot_count; - walks every allocated block in
cleanup()anddebug_objects(); - rebuilds the printed ID from the slot position;
- frees every block at cleanup.
It also adds a unit test, which fails without the change: 202 counted instead of 1098, and 798 of 1000 objects visited.
| Check | Official 26.3-stable | With the fix |
|---|---|---|
OBJECT_COUNT change after creating 1000 objects |
-24 | +1000 |
Orphan nodes found by get_orphan_node_ids() |
0 of 3 | 3 of 3 |
Leaked instance: lines for the 3 leaked nodes |
none | 3, with IDs matching get_instance_id() |
Steps to reproduce
- Download and extract the attached MRP.
- Import it once:
redot --headless --path <mrp> --import. - Run:
redot --headless --audio-driver Dummy --path <mrp> --verbose. - The output shows the wrong
OBJECT_COUNTdifference, 0 of 3 orphan nodes, and a leak warning with noLeaked instance:lines.
Minimal reproduction project (MRP)
- Lingua principale
- C++
- Stelle
- 6.1k
- Fork
- 337
- Merge medio
- 5g 8h
- PR unite (30g)
- 13
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Redot-Engine/redot-engine
-
C#] [Export] does not support struct types (GD0102), inconsistent with GDScript struct supportApertaenhancement topic:dotnet usability
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Redot-Engine/redot-engine#1589 ·
I maintainer di solito rispondono entro 1 giorno
-
Trait is not being resolvedApertabug topic:gdscript
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
Redot-Engine/redot-engine#1588 ·
I maintainer di solito rispondono entro 1 giorno
-
Handle stateful audio effects when a bus channel becomes inactiveForse già presa @GeneralProtectionFault l’ha presa 27 giorni fa. Aperta
Redot-Engine/redot-engine#1584 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
bug usability
Difficoltà 3/5 1-2 giorni Idoneità per principianti 53/100
Redot-Engine/redot-engine#1583 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug confirmed topic:3d topic:rendering
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Redot-Engine/redot-engine#1568 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Redot-Engine/redot-engine
Issue simili
-
Make the HTTP server's keep-alive and headers timeouts configurableForse già presa @mattgodbolt l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
compiler-explorer/compiler-explorer#9902 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Nixtla/statsforecast#1371 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfForse già presa @fedonman l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
task
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
SparseLinearAlgebra/spla#316 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno