Skip to content

#3123: slot producers and destroyers are proven; a prototype c_import does not import is no contract item - #3263

Merged
ehartford merged 2 commits into
opaque-void-typedeffrom
ptr-to-ptr-proofs
Nov 11, 2026
Merged

ehartford merged 2 commits into
opaque-void-typedeffrom
ptr-to-ptr-proofs

Conversation

@ehartford

@ehartford ehartford commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor
  • A producer that allocates through a callee's out parameter (open(&data); return data;) and a destroyer that frees through a pointer to its pointer (close(&data)) are proven from the callee's body. One proven shape and four refused ones in test/internals/conan_facade_slot_producer_destroyer_test.w.
  • On libcurl 8.23.0: curl_easy_init/curl_easy_cleanup and curl_share_init/curl_share_cleanup are a producer and a destroyer; 21 of 100 functions presented (was 17); a program with no unsafe makes and drops an easy handle.
  • The first battery on this stack failed the libxml2 UAT: a newly proven producer named __xmlParserInputBufferCreateFilename was written into the generated file, and c_import imports no function whose name starts with _. Such a prototype is now internal. The fixture is untouched.

Battery: GREEN on this commit 282e783 (seed-driven, with uat --strict).

Eric Hartford added 2 commits November 11, 2026 12:55
…oyer that frees through a pointer to its pointer are proven

libcurl's curl_easy_init is `Curl_open(&data); return data;` and
curl_easy_cleanup is `Curl_close(&data)`. Both read as 'local data is stored
or its address taken'. Three evidence records say what happens at a slot:
`localaddr` (the address of a local passed to a named callee), `outstore`
with `localout` (a store through the slot a parameter points at), and
`localslot` (a local loaded from it).

- A callee whose every store through the slot is NULL or an allocation
  nothing else keeps hands its caller a fresh allocation (fd_out_fresh).
- A callee that loads the slot into a local and frees it destroys what the
  caller's local stands for (fd_slot_destroys).
- Anything else is the store it was: a callee that also keeps the pointer,
  one that also returns it, a closer that frees nothing, a slot filled from
  a parameter. The address of a local standing for a parameter, passed to a
  callee not proven to free, is judged after destruction is known and
  counts as retention.

Test: test/internals/conan_facade_slot_producer_destroyer_test.w (one proven
shape, four refused).
The battery's libxml2 scenario failed: the new slot proofs prove
`__xmlParserInputBufferCreateFilename` a producer, the drafter wrote
`from __xmlParserInputBufferCreateFilename`, and the facade was refused
('not a declaration in scope'): c_import imports no function whose name
starts with `_`. Any prototype counted as API; one c_import does not read
is now the library's own, like a definition with no prototype.

Test: conan_facade_slot_producer_destroyer_test.w gains a proven producer
named `__good_init_internal`; without the fix the facade lists it.
@ehartford
ehartford added this pull request to stack #3264 November 11, 2026 21:15
@ehartford ehartford changed the title ptr to ptr proofs #3123: slot producers and destroyers are proven; a prototype c_import does not import is no contract item Nov 11, 2026
@ehartford
ehartford marked this pull request as ready for review November 11, 2026 21:15
@ehartford
ehartford merged commit e33c393 into main Nov 11, 2026
@ehartford
ehartford deleted the ptr-to-ptr-proofs branch November 11, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant