You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preprocessor macros interrupt argument extraction for C/C++ functions #1837
bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginepriority: mediumtestingUnit, integration, and E2E pipeline verification
name: Preprocessor macros interrupt argument extraction for C/C++ functions
Description
In gitgalaxy/core/detector.py, the regex-based argument extraction fails to correctly count arguments when the parameter list or the area immediately following the signature contains preprocessor directives like #ifdef, #else, and #endif.
Because GitGalaxy slices the args_search_text up to the first open brace { for C, functions whose signatures are duplicated across #if/#else blocks result in an args_search_text string containing multiple conflicting signatures mixed with preprocessor tokens. The strict args regex fails to parse these properly, leading to incorrect argument counts.
Impact
This causes a discrepancy between args_exact_match and args_comparable in C and C++, as GitGalaxy either returns args_count=0 or extracts arguments from the wrong preprocessor branch. Tree-sitter, on the other hand, evaluates the AST and can drop unparsed nodes or resolve the syntax more robustly.
Example
gc_mark_subtree in language-crucible/data/c/micropython/gc.c is defined as:
GitGalaxy incorrectly extracts arguments due to the #else block intersecting the regex search space, leading to an argument mismatch compared to tree-sitter.
Proposed Fix
Implement a preprocessor stripping pass for C/C++ in args_search_text before applying the args_pattern, or update the args regex to tolerate and skip over #if, #else, and #endif boundaries when matching parameter lists.
I have verified that this issue is already fully resolved.
Commit 3bed75a4 introduced a specific re-slicing pass for C/C++ in detector.py (inside _slice_by_braces) that detects when a signature is duplicated across an #if/#else branch immediately preceding the function body (which is exactly the shape of gc_mark_subtree in micropython/gc.c). It isolates the #else branch by stripping everything before the last #else or #elif directive, provided the preceding text ended in a complete signature.
As a result, GitGalaxy now correctly extracts 1 argument for gc_mark_subtree, matching Tree-sitter's output. The tree_sitter_accuracy_audit.py script confirms 100% argument exact match (1702/1702) for the C language-crucible test set.
Closing this issue as it is already implemented and verified in main.
bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginepriority: mediumtestingUnit, integration, and E2E pipeline verification
Activity
Correct overclaim in c.md, cross-reference pre-existing args issues, …
Fix 4 C/C++ arg-count extraction bugs in detector.py (#1884)
squid-protocol commentedon Aug 22, 2026
I have verified that this issue is already fully resolved.
Commit
3bed75a4introduced a specific re-slicing pass for C/C++ indetector.py(inside_slice_by_braces) that detects when a signature is duplicated across an#if/#elsebranch immediately preceding the function body (which is exactly the shape ofgc_mark_subtreeinmicropython/gc.c). It isolates the#elsebranch by stripping everything before the last#elseor#elifdirective, provided the preceding text ended in a complete signature.As a result, GitGalaxy now correctly extracts 1 argument for
gc_mark_subtree, matching Tree-sitter's output. Thetree_sitter_accuracy_audit.pyscript confirms 100% argument exact match (1702/1702) for the C language-crucible test set.Closing this issue as it is already implemented and verified in
main.