Skip to content

objective-c args extraction: untyped keyword-message params undercount to 0, and body content can leak into the count #1335

Closed

Description

@squid-protocol

What

While investigating #1314's objc func_start precision fix (PR #1328) and its bodyless-@interface-declaration follow-up (PR #1332), args-count verification against language-crucible/data/objective-c/worldwideweb surfaced two related, unfixed gaps in objc's args extraction. Both are real, confirmed-against-corpus GitGalaxy defects (not measurement-tool artifacts).

1. Untyped keyword-message parameters undercount to 0. GitGalaxy's args regex (language_standards.py's objc "args" rule, branch 1) requires a (Type) cast between each label: and its parameter name. Older, still-valid Objective-C style omits the type (defaults to id) -- e.g. - back:sender { ... }, - help:sender, + setManager:aManager. None of these are recognized as having any parameters at all (args=0 instead of 1+). Confirmed via HyperManager.m: back, help, save, open, traceOn, searchRTF, and roughly 15 others in that one file alone.

2. When a method's own signature doesn't match ANY args branch (case 1 above, or a genuinely zero-arg method with no colon at all), args extraction falls through past the real signature and matches the first C-style-shaped call/statement found later in the method's own body -- because args_pattern.search(block) searches the whole sliced function body, not just the signature line. Confirmed concretely:

  • Anchor.m's - free { if (Address) free(Address); ... } (zero-arg, no colon) measures args=1, borrowed from the free(Address); call inside its own body.
  • HyperManager.m's - closeOthers:sender { ... printf("...", w); ... } (1 real untyped param) measures args=2, borrowed from the unrelated printf(...) call's 2 comma-separated arguments.

This is the same architectural shape as #1221's "Invocation Shield" (bare call statements false-positive-matching as function signatures), but for objc's args regex specifically rather than func_start -- #1221's fix didn't cover this pillar/language combination.

Why this needs care, not a quick regex patch

Simply making the (Type) annotation optional in branch 1 would fix (1) and most instances of (2), but risks a new false positive: a ternary expression later in a method's body (cond ? a : b) would then also match the loosened "optional-parens colon segment" shape, since parens would no longer be required to distinguish a real keyword-message parameter from an unrelated label : value shape. This exact corpus (1990s NeXTSTEP-era C) uses ternaries. Any fix needs either:

  • A proper "Invocation Shield" for objc's args regex (bound the search to the actual signature span, not the whole body), or
  • Careful adversarial testing (per how_to_add_a_language.md's methodology) against ternary/nested-conditional shapes before loosening branch 1.

Suggested next step

Start with tests/extraction/languages/test_objectivec.py's args gauntlet + tests/core_engine/test_detector.py's _count_colon_selector_segments unit tests as the adversarial-case baseline. Consider anchoring the args search to a bounded prefix of block (up to the first real terminator) rather than the whole body, which would structurally prevent case (2) regardless of case (1)'s outcome.

Related: #1314, #1221, #1261 (parent epic)

Activity

  1. added
    bug
    core-engine
    threat: false-positive
    on Aug 12, 2026
  2. added a commit that references this issue on Aug 13, 2026
    c2831f2
  3. added this to the v2.4.8 milestone on Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginethreat: false-positive

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions