Skip to content

Facade proof: retention 'passed to a callee no unit defines' (996 functions, 15 libraries): a static inline, macro-generated or other-unit callee ends the trail as unproven #3174

Done

Description

@ehartford

Part of #3115; cluster from the #3116 survey: 'retains a parameter, passed to a callee no unit defines; not proven', 996 functions in 15 libraries (glfw's platform dispatch setWindowTitle, zlib inflateBack's callbacks, …). Also 'a chain of calls too deep to follow' (47 functions, 6 libraries). The proof should say which callee and why it is undefined (a function pointer field, a platform file not configured, a depth limit) so the registry fact can be written; and dispatch through a struct of function pointers to a configured backend is a resolvable case.

Activity

  1. added
    bug
    on Nov 9, 2026
  2. added 2 commits that reference this issue on Nov 9, 2026
  3. ehartford commented on Nov 9, 2026

    @ehartford
    ContributorAuthor

    The dispatch shape is said honestly since #3202 (main 61b5199): a parameter passed through a function-pointer field reads 'passed through the function pointer field X, which no unit decides' (glfw's platform dispatch), and a field named free/malloc is no longer taken for the libc call (Law 4). What remains: a registry convention for dispatch tables, and the 47 'chain of calls too deep to follow' functions.

  4. added 3 commits that reference this issue on Nov 9, 2026
  5. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    #3418 merged: a retained parameter's chain of calls is followed to the store that ends it, so the 47 "too deep to follow" functions now name where the value ends up. With #3202 (dispatch through a function-pointer field is said as such), what is left here is the registry convention for dispatch tables: how a registry states which functions a table's field may hold. That is contract-language design, so it waits on Eric.

  6. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Brief: a call through a function-pointer field the package fills itself (#3174, #3206 shape 1)

    The question. _glfw.platform.setWindowTitle(window, title) calls through a field. Today the proof stops: "passed through the function pointer field X, which no unit decides", and the function is raw. That is 1648 functions in 14 libraries, the largest raw cluster. Shape 2 of #3206 (allocator hooks the user may replace) is already ruled: field F of R is allocator | reallocator | deallocator | context, stated, never drawn. This brief is the other shape: a table only the library fills.

    1. What the others do. None of them models it. Their C importers hand a function-pointer field over as a raw nullable pointer and stop (Rust's bindgen, Zig's translate-c, Swift's importer). This is from knowledge, not checked in .reference: bindgen is not in the Rust tree there.

    2. What the spec says. It already has the rule, for another proof. §31.8.5 rule 4 (adopted 2026-11-11, not built): "Every indirect call resolves. A call through a pointer reaches a function whose address something took. An address taken inside the library is a reference … Any other source fails the proof." §31.8.6 does the same for one global (xmlFree): the library assigns it only in functions that stay raw. Nothing says a retention proof may use it.

    3. The proposal. A call through field F of record R reaches one of the functions the package stores into F. The verdict is the join over that set: a parameter is retained if any of them retains it; a return is owned only if all of them return owned. It holds only when all of these hold, and otherwise the function stays raw, naming the first that failed:

    1. Every unit of the build was read (the rule of §31.8.5).
    2. Every store to F is an assignment or an initializer whose value is a function the package defines.
    3. A whole R is written only by an initializer or by copying another R. A memcpy into one, or a cast of another pointer to R *, fails.
    4. The address of F is never taken.
    5. No presented operation lets the program supply an R or write F (R is not a fills or updates value record, and F has no stated role).
    6. The library is built from the source that was read. A prebuilt binary proves nothing here, as for every other proof.

    Where the proof fails and a person knows the answer, the registry states it: field F of R holds f, g, a counted claim with its citation.

    4. Mission fit. The compiler proves what the library's own source already determines; the programmer writes nothing. The conditions are enumerable (D198), and a wrong answer needs a store the six conditions do not allow.

    Prediction. Yes to the proof with those six conditions: 75%. Yes to holds as the stated fallback: 65% (you may prefer no fallback until a library needs it).

    First step, if yes. A measuring build that reports, per library, how many of the 1648 the proof would decide and which condition stops each of the rest. It changes no verdict.

  7. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Correction to the brief above, from reading the code and the survey after writing it.

    The proof already exists for one writer (D198, fd_draw_fnptr_verdicts): a field the package writes in exactly one place, with a named function, in a record that is never passed to a function the proofs cannot read, never cast, and never initialized by an unmapped initializer, is that function. Its conditions are the six I listed. So the proposal is not a new proof; it is two extensions of that one:

    1. Several writers. A field written in several places, each with a named package function, is the join over them (retained if any retains; owned only if all return owned). Today: 'written in several places', 84 functions in the 2026-11-10 survey.
    2. A record passed to a call through such a field. Today that fails the record ('a pointer to the record is passed to a function pointer, which the proofs cannot read'). With the callee set of that field closed and every member read, the record has not left what the drafter sees. This is the large one: 'the record is passed to a function the proofs cannot read' is 1452 of the cluster's functions, and in xz_utils (pinned 5.8.4) 10 of its 16 undecided callees fail for exactly this reason, at common.c:129. It needs a fixed point, since tables call through tables.

    The measurement I offered is therefore mostly in the survey already; what a measuring build adds is how many of the 1452 are a call through a field (decidable by extension 2) and how many are a real outside function.

  8. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Survey over the library list with the split (main + the survey fix, darwin-aarch64, 2026-11-18; 22 libraries fetched, read from each library's source evidence):

    why the field is undecided functions libraries
    the record is passed to a call through a function pointer 1091 retained + 47 returned 6
    the record is passed to an outside function the proofs cannot read 368 + 3 5
    an initializer or field address the proofs cannot map 83 + 1 3
    written in several places 74 + 10 9
    its one write is not a named function 54 4
    a unit could not be read 40 2
    the record is converted to another pointer type 20 4
    the package never writes it 3 1

    So extension 2 of the brief (a record passed to a call through a field whose callee set is closed) is the reason for 1138 of the cluster's functions, and extension 1 (several writers) for 84 directly; extension 2 depends on extension 1 wherever the inner field has several writers.

  9. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    Labelled human attn needed. What is left here waits on one ruling, already written up as a brief on this issue: whether the proofs may follow a record passed to a call through a function-pointer field when the set of functions that field can hold is closed (1,138 of the cluster's functions), and the several-writers extension it depends on (84). #3176's remaining misread (yyjson) and #3206's shape 1 go with the same ruling.

  10. ehartford commented on Nov 25, 2026

    @ehartford
    ContributorAuthor

    Ruled by Eric, 2026-11-25 (answers to briefs.md).

    A: both extensions, under the six conditions, gated on the measuring build. Three conditions on the yes:

    • Fixed point. The words say which one. 'Retained' is the least fixed point (a retention needs a real store as witness). 'Returns owned' must be grounded: a cycle through the tables cannot prove ownership by assuming it.
    • Per-target verdicts. The survey was darwin-aarch64 only and GLFW's platform table is filled by different units per platform. 'Every unit of the build was read' holds per build configuration.
    • holds is deferred until the measuring build shows what A leaves undecided. If it comes later it is checked against every store the drafter can see.

    Order: the measuring build (changes no verdict), then the proof. #3206 shape 1 and #3176's yyjson misread go with it. Label removed; this is mine.

  11. ehartford commented on Nov 27, 2026

    @ehartford
    ContributorAuthor

    Measured on 673ca2631 across the 23 buildable libraries on the #3115 list (after D211 / #3470 landed both extensions):

    • written in several places: 84 → 0
    • record passed to a call through a field the proofs do not close: 1,138 → 51 (95% eliminated; remaining 39 in glfw macOS Objective-C _glfwConnectCocoa, 10 in xz_utils lzma_filter_info_s.init)
    • chain of calls too deep to follow: 53 → 0
    • Verified retains is least fixed point and owns_return is grounded, with explicit cycle tests added in test/internals/conan_facade_fnptr_field_proof_test.with.
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions