Skip to content

Facade proof: 'stored in a global' (187 functions, 14 libraries) and 'stored through a local' (165) read as retention; most are a gzgets-style scratch write or a debug hook #3175

Done

Description

@ehartford

Part of #3115; clusters from the #3116 survey: 'retains a parameter, stored in a global' 187 functions (zlib gzgets, …), 'stored through a local' 165 (zlib crc32), 'stored' 156 (deflateSetDictionary). Sibling of #3124 (self-state stores). Each needs a look at what the store is: a copy of bytes (no retention), a write through a local alias of the parameter (a store into the parameter, not of it), or a real registration. The proof conflates 'wrote through p' with 'kept p'.

Activity

  1. added
    bug
    on Nov 9, 2026
  2. added a commit that references this issue on Nov 9, 2026
  3. ehartford commented on Nov 9, 2026

    @ehartford
    ContributorAuthor

    Two shapes fixed in #3200 (main 659ae4f): a parameter assigned to a local of the body is an alias, not a store into a global (zlib gzgets' str = buf), and a write into the parameter's own variable stores nothing (crc32_z's buf = (const unsigned char *)words). Left here: the plain 'stored' shape (paramstore, 156 functions, deflateSetDictionary) and whatever 'stored through a local' remains after the next survey; both need their C read the same way (WITH_KEEP_BUILD=1 keeps a fetch's tree).

  4. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Report half landed in #3432: a stored parameter is reported with the place it was stored in, as the source spells it (retains param 1 (stored in a field, strm->next_in)), so a reader can tell a registration from a scratch slot.

    What reading zlib's C showed for the proof half (pinned zlib 1.4, kept build tree):

    • gz_read (gzread.c) leaves the caller's buffer in state->strm.next_out after the call returns. That is a real stale pointer in the record; the next call overwrites it before use.
    • deflateSetDictionary (deflate.c) saves strm->next_in, points it at the dictionary, runs fill_window, and restores it.

    Neither is provable as 'not retained' without following a pointer through a record field across calls. They are the same shape as #3173 (a buffer paired with fields of the record, cleared after the call), so the remaining 'stored in a field' cases of this kind move with that ruling, not with a looser proof here.

  5. ehartford commented on Nov 18, 2026

    @ehartford
    ContributorAuthor

    Needs Eric: the report half landed (#3432). The remaining 'stored in a field' cases read in zlib are a buffer left in or swapped through the stream record, which is #3173's field-pairing clause, awaiting his ruling on that brief.

  6. ehartford commented on Nov 23, 2026

    @ehartford
    ContributorAuthor

    A concrete case for the "stored through a local / out-pointer" half, read from the pinned libcurl 8.23.0 (lib/mprintf.c 151 to 159), reached now that #3570 removed the false va_start stop:

    static int dollarstring(const char *p, const char **end)
    {
      …
      *end = p;            /* a pointer into the caller's string, handed back */
      return (int)num - 1;
    }
    …
    precision = dollarstring(fmt, &fmt);     /* callers pass the address of their own local */

    The proofs read *end = p as a store, so curl_mprintf's format is "retained" (… passed to dollarstring at param 0, stored in *end``). Nothing is kept: the callee returns a pointer derived from p through an out-parameter, and each caller passes the address of a local in its own frame that already stands for the same parameter. It is `strtol`'s `endptr` shape.

    The rule that would decide it: a parameter (or a pointer derived from it) written through another parameter's slot is returned through that parameter, not stored; the caller is then judged by what it passed for the slot. The address of one of its own locals: the local now stands for the parameter (it is followed like any alias). Its own out-parameter: the caller returns it the same way. Anything else (a field, a global): retained, as today. A public function that returns its parameter this way stays raw until a facade can state the borrow.

    That extends what the proofs accept as "not kept", so it is a proof-rule decision (D198: enumerable; D51: a wrong inference here grants a lend). Bringing it to Eric as a brief; not implemented.

  7. ehartford commented on Nov 24, 2026

    @ehartford
    ContributorAuthor

    Labelled human attn needed: the out-parameter rule in the comment above (a parameter written through another parameter's slot is returned through it, not stored) is a proof-rule decision. The case it would decide is libcurl's dollarstring, the same shape as strtol's endptr.

  8. ehartford commented on Nov 25, 2026

    @ehartford
    ContributorAuthor

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

    A: a parameter (or a pointer derived from it) written through another parameter's slot is returned through that parameter, not stored, the caller judged by what it passed for the slot. First cut limited to a direct write through the parameter (*out = p); out->field = p stays a store. Public functions that return a parameter this way stay raw. Label removed; this is mine.

  9. added a commit that references this issue on Nov 27, 2026
    fb0a174
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