fix(c-lsp): cap expression type evaluation steps#323
Conversation
3a5e9bf to
915ccb9
Compare
|
Thank you again, @romanornr! 🙏 Great follow-up to #322. The insight that a recovery-mode C++ AST can drive member/type lookup repeatedly without increasing recursion depth — so the existing Merged via squash ( |
Issue #355 reported a segfault extracting a macro-heavy xxhash C header (dhw/xx_hash.h, not available to us). Add a guard that runs the vendored xxhash.h (~7.5k lines, same macro-dense family) through C extraction under ASan. It passes on current main — the C-LSP crash hardening (#322/#323/ #360) appears to cover this class. Kept as a regression guard; #355 stays open pending the reporter's confirmation/file.
Adds a per-file expression-eval step budget (10k) to the C/C++ LSP resolver so pathological recovery-mode ASTs degrade to unknown instead of hanging indexing (the Bitcoin-derived C++ repro). Verified locally: build clean, all 3,617 tests pass including the full clsp_ suite.
Summary
unknownafter the budget is exhausted instead of allowing pathological expression/type lookup loops to hang indexingWhy
While indexing a large Bitcoin-derived C++ codebase, one worker could hang indefinitely in
c_eval_expr_type()/c_eval_expr_type_inner()during definition extraction. The minimal repro was a single C++ test file with many versionbits-style checks; GDB showed repeated C++ expression evaluation through member/type lookup rather than a crash.This guard trades a small amount of precision in pathological files for keeping repository indexing bounded and useful.
Test plan
make -f Makefile.cbm test -j$(nproc)Related
Follow-up to #322, which fixes a separate C++ LSP crash path.