Repository navigation
fix(cpp): an overload chosen by arguments that call it again no longer overflows the stack - #2999
Closed
JosefAschauer wants to merge 1 commit into
Closed
JosefAschauer wants to merge 1 commit into
JosefAschauer wants to merge 1 commit into
Conversation
…r overflows the stack cppArgumentTypeChoice types a call's arguments to pick among tied overloads. In `extras(extras(id).prev())` on a class with a const and a non-const `extras(id)`, typing the argument types `extras(id)`, whose overload is chosen by the arguments of the call the reference is at - the outer one - and cppArgumentType restarts cppExpressionType's depth at 0 on each lap. The recursion never ended and the whole index run failed with "Maximum call stack size exceeded" (darts-clone's darts.h reproduces it). A choice that comes back to the same call now takes the first overload, as one whose argument types are unknown does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018hJjBUPFiLSFBssshFwHzq
colbymchenry
pushed a commit
that referenced
this pull request
Oct 30, 2026
…r overflows the stack On main, indexing darts-clone failed in "Resolving refs" with "Maximum call stack size exceeded", and the whole run was lost. darts.h writes `extras(extras(id).prev()).set_next(extras(id).next())` on a class with a const and a non-const `extras(id)`. Choosing between them types the arguments; typing `extras(id).prev()` types `extras(id)`, whose overload is chosen by the arguments of the call the reference is at, the outer one, so the same arguments are typed again. cppArgumentType restarts cppExpressionType's depth at 0 on each lap, so the depth bound never trips. cppArgumentTypeChoice now keeps the calls whose arguments it is typing (`file:line:column:name`), and a choice that comes back to the same call takes the first tied overload, the answer it already gives when no argument's type is known. A try/finally clears the entry. Validation on main 5526e33 (Windows 11): - Red/green: the new test fails with main's name-matcher.ts (RangeError: Maximum call stack size exceeded) and passes with the fix. - A/B against main: darts-clone fails on main and indexes with the fix, 503 more linked sites (897 edges against the 394 the failed run left), with `reserve_id` and `expand_units` reaching `extras`, `prev`, `next`, `set_prev` and `set_next`. leveldb, fmt, googletest and nlohmann/json are byte-identical, as are the express and flask controls. - Index time unchanged: median of 3 interleaved runs on nlohmann/json, 15.9 s on main and 16.0 s with the fix. Original PR #2999 by @JosefAschauer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks for tracking down this crash and for the minimal reproduction, @JosefAschauer! It landed in #3078 with you as the author, and your guard and test are unchanged. On our A/B, darts-clone now indexes fully instead of failing, with 503 more linked call sites, while leveldb, fmt, googletest and nlohmann/json come out identical. We only moved the changelog entry next to the other C++ entries and named darts-clone in it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On current
main,codegraph indexof a 5.5k-file repository fails in "Resolving refs" withRangeError: Maximum call stack size exceeded, and the whole index run is lost (the index is left truncated). v1.6.2 indexes the same repository fine.The stack cycles through the C++ overload choice added with argument-type fitting (a6ceb04 / 4a591ae):
The trigger is darts-clone's
darts.h:extras(extras(id).prev()).set_next(extras(id).next());on a class with
const extra_type &extras(id_type) constandextra_type &extras(id_type). Typing the argumentextras(id).prev()typesextras(id). Its overload is chosen by the arguments of the call the reference is at, which is the outer call (cppCallArguments(ref, …)), so the same arguments are typed again.cppArgumentTyperestartscppExpressionType's depth at 0 on each lap, so the existing depth bound never trips.Fix
cppArgumentTypeChoicekeeps the calls whose arguments it is typing (file:line:column:name). A choice that comes back to the same call takes the first tied overload. That is the answer it already gives when no argument's type is known.try/finallyclears the entry.Validation
__tests__/cpp-overload-argument-reentry.test.ts: a 20-line class with the same shape. Onmainit fails with theRangeError; with the fix it indexes, andunlinklinksextras,set_nextandset_prev.npx tsc --noEmit: clean.main:bundle-launcher×2: nozipbinary.cli-sync×2: the host runs Node 26, which prints the unsupported-Node banner.🤖 Generated with Claude Code
https://claude.ai/code/session_018hJjBUPFiLSFBssshFwHzq