Repository navigation
Commit 77ab4be
committed
fix(extract): definitions walk stack grows without a ceiling
walk_defs keeps its pending frames in a growable stack that was bounded by
an 8M-frame ceiling (env CBM_WALK_DEFS_MAX). At the ceiling wd_push logged
"extract.walk_defs_capped" once and then stopped pushing. Children are
pushed last-to-first, so a file wider than the ceiling lost its FIRST
definitions: a work cap decided graph content.
Fix: no ceiling. The stack doubles on demand, heap frames now come from the
memory core (cbm_realloc/cbm_free, class EXTRACT) instead of safe_realloc and
raw free, and the doubling is overflow-guarded (int capacity and size_t
byte count). The only thing that can stop the walk is an allocation failure,
and that is loud: logged at error level as "extract.walk_stack_alloc_failed"
(walker=walk_defs, pending, path) -- the same event the complexity walkers
use -- and the file's result is marked has_error with
"definitions walk: stack allocation failed", which the definitions passes
already report as a per-file extract error. The arena-backed path
(ctx->scratch) gets the same failure handling. Traversal order is unchanged.
CBM_WALK_DEFS_MAX is removed. It was read only in wd_stack_max(); it was not
documented anywhere (docs, --help, config, tests), so nothing else changes.
extract_defs.c loses its raw free() call, so the memory-core baseline for
the file drops from 5 to 4.
Test (extraction suite): walk_defs_wide_file_extracts_every_definition
extracts a C file with 1000 top-level functions with CBM_WALK_DEFS_MAX=256
set, and asserts every wd0..wd999 definition is present. RED on main
(extract.walk_defs_capped limit=256; wd0 missing), GREEN with the fix, RED
again with the production change reverted. The extraction (379), complexity
(5), ast_profile (10) and semantic (35) suites pass.
Real input: Linux kernel, index-only, fresh cache and runtime dirs, same
machine. main and fix both produce 8,530,336 nodes and 15,764,128 edges,
SEMANTICALLY_RELATED 607 each, and the full node set (label, QN, lines) and
edge set (type, source QN, target QN) hash identically -- no kernel file
approaches the old ceiling. Index wall time 210.0 s (main) vs 194.4 s (fix),
within run-to-run noise.
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>1 parent 64c23fa commit 77ab4be
3 files changed
Lines changed: 95 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | | - | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
7195 | 7196 | | |
7196 | 7197 | | |
7197 | 7198 | | |
7198 | | - | |
7199 | | - | |
7200 | | - | |
7201 | | - | |
7202 | | - | |
| 7199 | + | |
| 7200 | + | |
| 7201 | + | |
| 7202 | + | |
| 7203 | + | |
| 7204 | + | |
| 7205 | + | |
7203 | 7206 | | |
7204 | 7207 | | |
7205 | 7208 | | |
7206 | 7209 | | |
7207 | | - | |
7208 | | - | |
| 7210 | + | |
| 7211 | + | |
7209 | 7212 | | |
7210 | 7213 | | |
7211 | 7214 | | |
7212 | 7215 | | |
7213 | 7216 | | |
7214 | | - | |
| 7217 | + | |
7215 | 7218 | | |
7216 | 7219 | | |
7217 | 7220 | | |
7218 | | - | |
7219 | | - | |
7220 | | - | |
7221 | | - | |
7222 | | - | |
7223 | | - | |
7224 | | - | |
7225 | | - | |
7226 | | - | |
7227 | | - | |
7228 | | - | |
7229 | | - | |
7230 | | - | |
7231 | | - | |
7232 | | - | |
7233 | | - | |
7234 | | - | |
7235 | | - | |
7236 | | - | |
7237 | | - | |
7238 | | - | |
7239 | | - | |
7240 | | - | |
7241 | | - | |
7242 | | - | |
7243 | | - | |
7244 | | - | |
7245 | | - | |
| 7221 | + | |
| 7222 | + | |
| 7223 | + | |
| 7224 | + | |
| 7225 | + | |
| 7226 | + | |
| 7227 | + | |
| 7228 | + | |
| 7229 | + | |
| 7230 | + | |
| 7231 | + | |
| 7232 | + | |
| 7233 | + | |
| 7234 | + | |
| 7235 | + | |
| 7236 | + | |
7246 | 7237 | | |
7247 | | - | |
7248 | | - | |
| 7238 | + | |
7249 | 7239 | | |
7250 | 7240 | | |
7251 | 7241 | | |
7252 | 7242 | | |
7253 | | - | |
7254 | | - | |
7255 | | - | |
7256 | | - | |
7257 | | - | |
7258 | | - | |
7259 | | - | |
7260 | | - | |
7261 | | - | |
7262 | | - | |
| 7243 | + | |
7263 | 7244 | | |
7264 | | - | |
7265 | | - | |
| 7245 | + | |
| 7246 | + | |
| 7247 | + | |
| 7248 | + | |
| 7249 | + | |
| 7250 | + | |
| 7251 | + | |
| 7252 | + | |
| 7253 | + | |
| 7254 | + | |
| 7255 | + | |
| 7256 | + | |
| 7257 | + | |
| 7258 | + | |
| 7259 | + | |
| 7260 | + | |
| 7261 | + | |
| 7262 | + | |
| 7263 | + | |
| 7264 | + | |
| 7265 | + | |
| 7266 | + | |
| 7267 | + | |
7266 | 7268 | | |
7267 | 7269 | | |
7268 | 7270 | | |
| |||
8070 | 8072 | | |
8071 | 8073 | | |
8072 | 8074 | | |
8073 | | - | |
| 8075 | + | |
| 8076 | + | |
| 8077 | + | |
| 8078 | + | |
| 8079 | + | |
8074 | 8080 | | |
8075 | 8081 | | |
8076 | 8082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5380 | 5380 | | |
5381 | 5381 | | |
5382 | 5382 | | |
| 5383 | + | |
| 5384 | + | |
| 5385 | + | |
| 5386 | + | |
| 5387 | + | |
| 5388 | + | |
| 5389 | + | |
| 5390 | + | |
| 5391 | + | |
| 5392 | + | |
| 5393 | + | |
| 5394 | + | |
| 5395 | + | |
| 5396 | + | |
| 5397 | + | |
| 5398 | + | |
| 5399 | + | |
| 5400 | + | |
| 5401 | + | |
| 5402 | + | |
| 5403 | + | |
| 5404 | + | |
| 5405 | + | |
| 5406 | + | |
| 5407 | + | |
| 5408 | + | |
| 5409 | + | |
| 5410 | + | |
| 5411 | + | |
| 5412 | + | |
| 5413 | + | |
| 5414 | + | |
5383 | 5415 | | |
5384 | 5416 | | |
5385 | 5417 | | |
| |||
8635 | 8667 | | |
8636 | 8668 | | |
8637 | 8669 | | |
| 8670 | + | |
8638 | 8671 | | |
8639 | 8672 | | |
8640 | 8673 | | |
| |||
0 commit comments