You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Facade proof: curl_version returns a static buffer it rewrites on each call; raw as "a pointer to no record" #3127
curl_easy_strerror returns a pointer to a string literal in a table; curl_version a static buffer. Both come out raw: "returns *const c_char, a pointer to no record". A const char * return the proof can trace to a string literal or a static array is returns static CStr; one it cannot trace stays raw with that reason. This is the most common return shape in C error APIs (strerror-likes, sqlite3_errstr, zError, SDL_GetError is borrowed-until-next-call, a different case).
Done when: literal- and static-buffer-returning functions present as static CStr from the proof; fixture.
Half fixed in #3254 (6940659): a function whose every return is a string literal now presents returns static CStr from the proof. On libcurl 8.23.0 curl_easy_strerror, curl_multi_strerror, curl_share_strerror and curl_url_strerror are callable from safe code.
Still raw: curl_version. It returns static char out[300] and rewrites the buffer on every call, so the storage is static but the text is not constant: a static view would alias memory a later call mutates. The safe presentation (copy to an owned str at the return, or refuse) changes what safe code may do, so it goes to Eric as a brief.
changed the title [-]Facade proof: functions returning static text (`curl_easy_strerror`, `curl_version`) are raw as "a pointer to no record"[/-][+]Facade proof: `curl_version` returns a static buffer it rewrites on each call; raw as "a pointer to no record"[/+]on Nov 11, 2026
curl_version stays raw ("returns *const c_char, a pointer to no record"). Its body is static char out[300]; … curl_msnprintf(out, …); return out;. The storage is static; the bytes are rewritten on every call. Two calls on two threads write the same buffer at once.
The same shape: strerror, inet_ntoa, asctime, setlocale, SDL_GetError (per thread), zError is a literal table (already presented).
1. What the others do (from memory; none of these bindings is in .reference/, so not verified in a tree). Rust's curl-sys declares curl_version in an extern block, so it is an unsafe call returning a raw pointer; safe wrappers copy into a String. Swift imports a const char * return as an unsafe pointer. Zig and Go (cgo) give the raw pointer. None models the buffer's lifetime.
2. What the spec says. §16.2b.7: "Foreign-state domains give ownerless C storage an origin: the process environment, locale, errno, diagnostic buffers, library caches." and "The default coarse domain of a library is its link identity." and "With … does not allocate a copy to hide an unknown one." §16.2b.6: "only genuinely immortal, immutable data is static (§16.2b.7), and static is never the default for 'C stored this globally'". D51's test lists dependency, invalidation and the coarse domain among what may be inferred silently (a wrong inference removes capability, never creates unsafety).
One sentence of the spec disagrees with the library: §16.2b.6 ends "text meant for printing comes through an operation whose return is modeled (curl_version() is returns static CStr)". By the proof, curl_version's text is not immutable. That sentence is yours; I have not touched it.
3. Mission fit. The program has determined nothing unsafe here: it wants to read a string. Leaving it raw makes the application developer write unsafe for the most common diagnostic call in C. Calling it static would be a lie the proof can see. The domain is the origin the spec already has for exactly this storage.
Options.
A. The proof presents it as a view of the library's domain. A function whose every return is one of its own static arrays (or a call of such a function) is drafted returns borrow CStr from domain <library>, the library's coarse domain. The view cannot be stored past the next call into the library that does not state preserves domain, and a process domain's view is not Send. No copy, no new grammar, no new rule: an inference from the list D51 allows.
B. The proof presents it as owned text copied at the return. Safe for one thread, but §16.2b.7 forbids the hidden copy, and a second thread's call during the copy is still a race.
(Presenting it static is not offered: the proof contradicts it. Leaving it raw is not offered: unsafe in an application for a version string.)
4. Prediction: A, 85%. It is the spec's own category ("diagnostic buffers"), it is the inference class the ruling permits, and it costs the user nothing: print(curl_version()) just works; holding the view across another libcurl call is refused with the ordinary view-liveness error.
What I need from you: A or B; and whether §16.2b.6's parenthetical about curl_version() should read returns borrow CStr from domain … (your words).
Built on a local branch as ruled 2026-11-17 (option A under the C-global rule): the proof drafts a function that returns its own static array as returns borrow CStr from domain <library>, and a call that returns a view of a process domain it does not preserve needs the one-thread proof (no task or thread in the program, and the library's contract says runs no threads), else it is refused outside unsafe. The two-thread program is refused at both calls.
Waiting on one scope answer from Eric before it can land: the rule keys on what the contract says (a process-domain view with no preserves domain), so it also reaches three existing tests whose hand-written contracts say that of getenv and localeconv. Yes: those tests gain the statement they lack. No: only proof-drafted functions carry the condition, which needs new grammar. Also waiting on his words for §16.2b.6 and §16.2b.7 (diff prepared, not landed).
Consequence to know: libcurl's contract does not say runs no threads, so curl_version() itself stays raw under this rule.
Activity
#3127: a function whose every return is a string literal presents as …
ehartford commentedon Nov 11, 2026
Half fixed in #3254 (6940659): a function whose every return is a string literal now presents
returns static CStrfrom the proof. On libcurl 8.23.0curl_easy_strerror,curl_multi_strerror,curl_share_strerrorandcurl_url_strerrorare callable from safe code.Still raw:
curl_version. It returnsstatic char out[300]and rewrites the buffer on every call, so the storage is static but the text is not constant: a static view would alias memory a later call mutates. The safe presentation (copy to an ownedstrat the return, or refuse) changes what safe code may do, so it goes to Eric as a brief.[-]Facade proof: functions returning static text (`curl_easy_strerror`, `curl_version`) are raw as "a pointer to no record"[/-][+]Facade proof: `curl_version` returns a static buffer it rewrites on each call; raw as "a pointer to no record"[/+]ehartford commentedon Nov 17, 2026
Brief (2026-11-17): a function that returns its own static buffer
The facts (main 6a29fb9, libcurl 8.23.0):
returnis a string literal is presented from the proof asreturns static CStr(#3127: a function whose every return is a string literal presents as static text #3254):curl_easy_strerror,curl_multi_strerror,curl_share_strerror,curl_url_strerrorare callable from safe code. That half of this issue is done.curl_versionstays raw ("returns *const c_char, a pointer to no record"). Its body isstatic char out[300]; … curl_msnprintf(out, …); return out;. The storage is static; the bytes are rewritten on every call. Two calls on two threads write the same buffer at once.strerror,inet_ntoa,asctime,setlocale,SDL_GetError(per thread),zErroris a literal table (already presented).1. What the others do (from memory; none of these bindings is in
.reference/, so not verified in a tree). Rust'scurl-sysdeclarescurl_versionin anexternblock, so it is anunsafecall returning a raw pointer; safe wrappers copy into aString. Swift imports aconst char *return as an unsafe pointer. Zig and Go (cgo) give the raw pointer. None models the buffer's lifetime.2. What the spec says. §16.2b.7: "Foreign-state domains give ownerless C storage an origin: the process environment, locale,
errno, diagnostic buffers, library caches." and "The default coarse domain of a library is its link identity." and "With … does not allocate a copy to hide an unknown one." §16.2b.6: "only genuinely immortal, immutable data isstatic(§16.2b.7), andstaticis never the default for 'C stored this globally'". D51's test lists dependency, invalidation and the coarse domain among what may be inferred silently (a wrong inference removes capability, never creates unsafety).One sentence of the spec disagrees with the library: §16.2b.6 ends "text meant for printing comes through an operation whose return is modeled (
curl_version()isreturns static CStr)". By the proof,curl_version's text is not immutable. That sentence is yours; I have not touched it.3. Mission fit. The program has determined nothing unsafe here: it wants to read a string. Leaving it raw makes the application developer write
unsafefor the most common diagnostic call in C. Calling itstaticwould be a lie the proof can see. The domain is the origin the spec already has for exactly this storage.Options.
returnis one of its ownstaticarrays (or a call of such a function) is draftedreturns borrow CStr from domain <library>, the library's coarse domain. The view cannot be stored past the next call into the library that does not statepreserves domain, and a process domain's view is notSend. No copy, no new grammar, no new rule: an inference from the list D51 allows.staticis not offered: the proof contradicts it. Leaving it raw is not offered:unsafein an application for a version string.)4. Prediction: A, 85%. It is the spec's own category ("diagnostic buffers"), it is the inference class the ruling permits, and it costs the user nothing:
print(curl_version())just works; holding the view across another libcurl call is refused with the ordinary view-liveness error.What I need from you: A or B; and whether §16.2b.6's parenthetical about
curl_version()should readreturns borrow CStr from domain …(your words).ehartford commentedon Nov 17, 2026
Built on a local branch as ruled 2026-11-17 (option A under the C-global rule): the proof drafts a function that returns its own static array as
returns borrow CStr from domain <library>, and a call that returns a view of a process domain it does not preserve needs the one-thread proof (no task or thread in the program, and the library's contract saysruns no threads), else it is refused outsideunsafe. The two-thread program is refused at both calls.Waiting on one scope answer from Eric before it can land: the rule keys on what the contract says (a process-domain view with no
preserves domain), so it also reaches three existing tests whose hand-written contracts say that ofgetenvandlocaleconv. Yes: those tests gain the statement they lack. No: only proof-drafted functions carry the condition, which needs new grammar. Also waiting on his words for §16.2b.6 and §16.2b.7 (diff prepared, not landed).Consequence to know: libcurl's contract does not say
runs no threads, socurl_version()itself stays raw under this rule.Spec v7.60, D208: a process domain names its writers (#3127). The par…
D208: a process domain names its writers; a writer's call is checked …