Skip to content

fix(c-lsp): cap expression type evaluation steps#323

Open
romanornr wants to merge 1 commit intoDeusData:mainfrom
romanornr:upstream/c-lsp-eval-step-budget
Open

fix(c-lsp): cap expression type evaluation steps#323
romanornr wants to merge 1 commit intoDeusData:mainfrom
romanornr:upstream/c-lsp-eval-step-budget

Conversation

@romanornr
Copy link
Copy Markdown

Summary

  • Add a per-file expression-evaluation step budget to the C/C++ LSP resolver
  • Return unknown after the budget is exhausted instead of allowing pathological expression/type lookup loops to hang indexing
  • Keep the existing recursion-depth guard, but also guard the non-stack-overflow case where evaluation repeatedly walks expensive C++ expression/type-resolution paths

Why

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)
  • Fresh fast index of the large C++ repro repository completed successfully after deleting its cache DB:
    • 2179 files
    • 29,766 nodes
    • ~91k edges
    • completed in ~8.6s

Related

Follow-up to #322, which fixes a separate C++ LSP crash path.

@romanornr romanornr force-pushed the upstream/c-lsp-eval-step-budget branch from 3a5e9bf to 915ccb9 Compare May 8, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant