Repository navigation
Description
Summary
with get c.libcurl (8.23.0, with v0.16.0.8, darwin-aarch64) writes a facade that presents 15 of 152 public functions safely. None of the API an HTTP client needs is among them: curl_easy_*, curl_slist_*, curl_mime_*. A project that just wants to make HTTP requests has to write the libcurl facade itself, which §16.2b.15 / D121 say a user never does for a with get package.
The generated .with/deps/c/libcurl/8.23.0/facade.w contains only CurlURL (curl_url/curl_url_dup/curl_url_cleanup) and six lends (curl_strequal, checkday, …).
Repro
with init . && with get c.libcurl
cat .with/deps/c/libcurl/8.23.0/facade.w
grep -E "curl_easy_|curl_slist|curl_mime" .with/deps/c/libcurl/8.23.0/facade-report.txtWhat the report says (excerpt)
facade libcurl: 152 functions, 15 presented safely, 137 raw; 3956 internal (no prototype declares them)
curl_easy_init: raw: returns *mut c_void, a pointer to no record
curl_easy_setopt: raw: retains param 0 (passed to Curl_eapi_enter at param 1, passed to Curl_ssl_scache_is_locked_by_current_thread at param 0, passed to cf_ssl_scache_get at param 0, passed to Curl_failf at param 0, passed to trc_write at param 0, stored); its lifetime contract is not proven
curl_easy_perform / curl_easy_cleanup / curl_easy_getinfo / curl_easy_reset / curl_easy_duphandle: (same "retains param 0" chain)
curl_slist_append: raw: retains param 0 (passed to Curl_slist_append_nodup at param 0, passed to slist_get_last at param 0, stored in a global); its lifetime contract is not proven
curl_slist_free_all: raw: retains param 0 (stored in a global); its lifetime contract is not proven
curl_mime: destroyed but never produced here; no resource
curl_mime_init: raw: retains param 0 (passed to Curl_rand_alnum ... passed to random, which no unit defines); its lifetime contract is not proven
curl_mime_free: destroyer, param 0 (proof: frees it)
curl_mime_addpart: raw: retains param 0 (stored in a field); its lifetime contract is not proven
curl_mime_name / _filename / _type: raw: parameter of unmodeled pointer type *mut curl_mimepart
curl_mime_data: raw: retains param 0 (passed to cleanup_part_content at param 0, stored); its lifetime contract is not proven
curl_easy_strerror: raw: returns *const c_char, a pointer to no record
curl_version_info: raw: returns *mut curl_version_info_data unproven: returns global state
Observations:
CURListypedef void CURL. Socurl_easy_initreturns*mut c_voidand is rejected as "a pointer to no record". The whole easy API hangs off avoid *handle, so this one refusal takes all of it out.- The "retains param 0" proof over-approximates. The handle passing through
Curl_eapi_enter/Curl_failf/trc_write/ the SSL session cache is the library storing its own handle in its own state. It isn't the caller's object being retained past the handle's lifetime.curl_easy_cleanupin particular is reported as retaining the handle it destroys. curl_slist_free_all"retains param 0 (stored in a global)" contradicts it being the list's destroyer. Likewisecurl_slist_appendis the list's producer (NULLin creates a list) and returns the head.curl_mimeis "destroyed but never produced" even thoughcurl_mime_initproduces it; the producer was refused for theCurl_rand_alnum → randomchain on the easy parameter (which may be NULL since 7.87.0).curl_easy_strerror/curl_versionreturn static text but come out raw ("a pointer to no record").
The registry has no c/libcurl/facts.w (only libxml2, zlib), so nothing backstops the proof.
Expected
At least the surface lib/facades/libcurl.w hand-models, presented safely by with get (proof or registry facts):
resource Easy(init / cleanup / abandon reset),setoptvariadic cases,perform,strerrorcurl_slistas a resource with append, plusCURLOPT_HTTPHEADERretaining itcurl_mime/ parts withCURLOPT_MIMEPOSTretaining itcurl_easy_getinfoforCURLINFO_RESPONSE_CODEand friends
Facade-grammar gaps hit while writing the project override
Writing that surface by hand in a project c facade libcurl: block, the compiler refuses these. A registry facts file would hit the same walls, so they are probably needed too (separate issues if you prefer):
- Variadic out-pointer cases.
case CURLINFO_RESPONSE_CODE: &mut c_long→ "a case states an integer C type ('c_long', 'curl_off_t', an enum) or 'str'".curl_easy_getinfohas no safe form. - A retained pointer case that is a resource.
case CURLOPT_HTTPHEADER: &HeaderList retains by param 0 until curl_easy_reset→ "a retained pointer case's type is caller-managed storage". The same applies toCURLOPT_MIMEPOST: &Mime. A list/mime resource borrowed by the easy handle for the transfer is the D194 retention shape with a resource instead of a buffer. - A producer whose resource parameter is NULL on creation.
fn curl_slist_append / rename new / param list fixed null→ "param 0 … receives a modeled resource; a resource is passed by the value that owns it, never fixed".curl_slist_append(NULL, s)creates;curl_slist_append(list, s)appends and returns the same head (or NULL, list untouched). curl_mime_init(easy)is presented onEasyand collides withEasy.new("function 'Easy.new' is already defined") even withrename newon the mime producer;param easy fixed nullhits gap 3.resource Part wraps *mut curl_mimepartwith no producer (parts are owned by the mime, fromcurl_mime_addpart) →returns borrow Part from param 0generatesBorrowedPart[Mime]that then fails as "unknown type: BorrowedPart".- A second callback pair on the same resource. With both
case CURLOPT_WRITEFUNCTION: … userdata param CURLOPT_WRITEDATA retains by param 0andcase CURLOPT_HEADERFUNCTION: callback param 2 as curl_write_callback userdata param CURLOPT_HEADERDATA retains by param 0, theHEADERFUNCTIONsetter call fails with "cannot infer generic method type parameter 'U'", while theWRITEFUNCTIONone compiles.
Workaround in use: the facade models Easy + scalar/string options + POSTFIELDS. curl_slist, curl_mime and getinfo are raw calls inside one safe With function that owns the list/mime as locals declared before the handle.
Activity
ehartford commentedon Nov 9, 2026
Split for tracking under the epic #3115: grammar gaps 1–4 are #3119–#3122 (5 and 6 were already #3114 and #3113); proof observations 1–5 are #3123–#3127; the registry facts for libcurl are #3143. This issue stays as the libcurl umbrella.
ehartford commentedon Nov 24, 2026
Labelled
blocked: this is the libcurl umbrella, and each remaining piece waits on a decision recorded on its own issue: #3119 (case K: fills Twords), #3120 (a retained case naming a resource), #3121 (a failed production that hands the input back), #3122 (the §16.2b.11 words and the version floor), #3124 (a library storing its own handle in its own state). The parts that needed no ruling are merged (#3588, #3589, #3590). It comes back when those are ruled.Bundle 2: registry facades and zero-unsafe UATs for libcurl, sqlite3,…