Skip to content

C call graph: calls through a #define alias (failf -> Curl_failf) are not linked #7828

Closed

Description

@squid-protocol

What's wrong. In C, a call written through an object-like macro alias isn't linked to the function it names. curl 7.30.0 has #define failf Curl_failf at lib/sendf.h:48 (infof likewise). Calls written failf(data, ...) aren't linked to Curl_failf: lib/ftp.c has 43 such sites, imap.c 19, url.c 18, smtp.c 16, and so on. libclang resolves them through the macro. They make up most of the 293 not_extracted/other edges callgraph_triage reports for that snapshot, where call recall vs libclang 18.1.1 is 65.4%. Precision is unaffected: 0 wrong confident links.

Repro. Run tests/tools/callgraph_triage.py c with corpus_repos pointed at a curl-7_30_0 checkout, then read the not_extracted/other samples, e.g. lib/connect.c:1103 failf(data, "Connection time-out");.

Suggested fix shape. In C, an object-like macro whose whole body is one identifier naming a function defined in the repository is an alias: resolve a call to the macro as a call to that function. A guarded alias (curl's infof also has Curl_nop_stmt / (void) variants under #if) links from the branch that names a function. If the engine doesn't evaluate #if, it links to every branch's function target.

Impact. Under-counted call edges, so function fan-in, function PageRank and cross-file fcall edges are low for logging/error helpers in older C code bases that alias them. Modern curl calls Curl_failf directly, and its recall is 86.4%.

How it was found. The same temporal-crucible validation as #7827 (the include issue): gitgalaxy's own call_graph_resolution._score and callgraph_triage, run with the libclang reference on curl and nDPI snapshots. Write-up: squid-protocol/temporal-crucible branch validate/engine-c, docs/engine_validation.md.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 5, 2026
  2. squid-protocol commented on Nov 5, 2026

    @squid-protocol
    OwnerAuthor

    Scale on openssl 3.5.0: the function-like form of this is the biggest C call-recall gap measured.

    callgraph_triage against libclang 18.1.1 finds 81,816 reference edges, 45,733 of them linked (55.9%; precision unaffected, 1 wrong link). The largest miss bucket is not_extracted/other at 17,087 edges. The leading call token on those lines:

    macro sites expands to
    ERR_raise 6,966 ERR_raise_data(...), then (ERR_new(), ERR_set_debug(...), ERR_set_error) (include/openssl/err.h.in:390)
    OPENSSL_free 3,220 CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE) (crypto.h.in:115)
    OPENSSL_malloc / _zalloc / _clear_free / _strdup / _realloc 601 / 582 / 348 / 159 / 74 CRYPTO_*
    ERR_raise_data 591 as above

    So the alias in this issue (#define failf Curl_failf) is the simple, object-like case. The same fix shape covers function-like macros: when a function-like macro's body is a call (or comma-list of calls) to repository functions, a call to the macro links to those functions. libclang counts them because it expands macros, so the cost to engine recall is large on macro-heavy C.

    Separate, and likely out of scope: about 8,800 caller_unmapped edges are functions that exist only after preprocessing. Examples are token-pasted definitions such as static int is_ ## type ## _fetchable(...) (apps/list.c:40) and generator macros such as DEFINE_OSSL_CMP_CTX_get0_NAME(trusted, trusted, X509_STORE) (crypto/cmp/cmp_ctx.c:38). Text-based extractors, tree-sitter and ctags included, can't see those. I'm recording it here for scale, not as part of the fix.

    🤖 Generated with Claude Code

  3. squid-protocol commented on Nov 12, 2026

    @squid-protocol
    OwnerAuthor

    Claimed by promoter-bot host melek, lease renewed 2026-11-12T22:18Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove the claim:melek label.

  4. squid-protocol commented on Nov 12, 2026

    @squid-protocol
    OwnerAuthor

    Closing: object-like aliases (#8364, curl failf -> Curl_failf, #if variants unioned) and the function-like #if-variant case (#8377) are merged; the C call-graph baseline moved (recall 50.8 -> 51.0%, precision 100%). Remaining sibling gaps (.h.in template headers, cross-file differing macros) are recorded in #8377's body and are not part of this issue's acceptance.

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

    bugclaim:melek

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions