Repository navigation
cimport: exempt stores of a resource pointer into its own exclusively owned sub-record (#3124) - #3648
Merged
Merged
Conversation
… owned sub-record (#3124)
Contributor
Author
|
Battery &
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements Eric's ruling on #3124 (2026-11-25, D235): a store of a resource's pointer is not retention when all four conditions hold:
R.Fof the resource's own record (directly viar->F->owner = r, via a local loaded fromr->F, or via a helperg(dst, src)that storessrconly intodst, transitively).Rdestroysr->F(directly, through helpers, or through a slot destroyer such asCurl_close(&data)).R.F(or a pointer into it, including conditional expressionse ? e->F : NULL), passesR.F(or a pointer into it) to a retaining callee, takes&r->Foutside a proven slot destroyer / fresh out-param, or storesR.Fanywhere else.R.Fassigns only a fresh allocation or restores its own previously loaded value, never copies from another resource or parameter, and destroys the old record on any non-constructor overwrite.Report-only verification across 23 libraries (#3115 list)
Ran report-only across all 23 buildable libraries before enabling verdicts (6,170 functions, 2,500+ record-pointer fields; summary posted on #3124):
libxml2: 7,libcurl: 5,raylib: 5), 0 false positives.expat'sXML_ParserStruct.m_dtd,libcurl'sCurl_easy.multi_easy,libevent'sevhttp_connection.bufev,libxml2's_xmlTextReader.*) were all rejected cleanly.Changes
src/CImport.with: recordrfset,rfload,rfsink,rfaddr,rfsubsink,rfescape,rfcall,paramstoreinto, andlocalstoreintoownership evidence (including conditional-op escape traversal).src/CiIR.with: storeowned_subrecord_fieldsonCiProject.src/CiFacadeDraft.with: prove exclusively owned sub-record fields under all 4 conditions (fd_prove_owned_fields_3124) and re-run retention/returns exempting proven self-owned stores.test/internals/conan_facade_self_owned_store_test.with: positive coverage (self-registering constructor, direct/local/1-hop/2-hop helper stores, overwrite-with-free, destroyer self-store) and negative coverage (cross-handle store, cross-handle helper, mixed helper calls, Condition 2 no-free, Condition 3 return & global escape, Condition 4 shared & unfreed overwrite).Closes #3124.