Skip to content

Facade proof: an opaque typedef void CURL handle is refused as "a pointer to no record", taking the whole libcurl easy API raw #3123

Closed

Description

@ehartford

Part of #3115; observation 1 of #3111.

curl_easy_init returns CURL *, and CURL is typedef void CURL, so the drafter sees *mut c_void and refuses it: "returns *mut c_void, a pointer to no record". Every easy function then lacks a resource to hang off.

An opaque handle behind typedef void T is a common C idiom (libcurl's CURL/CURLM/CURLSH, libuv-style handles, many vendor SDKs). The typedef name is evidence of identity even though the pointee is void: a pointer returned under a distinct typedef name, consumed by a function under the same name that frees it (curl_easy_cleanup(CURL *)), is a handle. The drafter should model the typedef as an opaque resource type (D121 evidence: producer and destroyer agree on the name), never collapse it to c_void.

Done when: with get c.libcurl presents Easy (init, cleanup, perform, reset) from the proof alone; the coverage table (#3116) shows the change.

Activity

  1. added 2 commits that reference this issue on Nov 11, 2026
  2. ehartford commented on Nov 11, 2026

    @ehartford
    ContributorAuthor

    Fixed in #3262 and #3263.

    • The drafter keeps a void typedef's name in the types it reasons over (*mut CURL), so a name a producer returns and a destroyer frees is a resource, and an operation on such a handle states of <Resource>. c_import still aliases the typedef to c_void: a distinct type would also catch pure synonyms (GLvoid, where const GLvoid * means any pointer), and the header cannot tell a handle from a synonym, so identity comes from evidence.
    • libcurl's producer and destroyer go through a pointer to the pointer (Curl_open(&data), Curl_close(&data)); those shapes are now proven from the callee's body.

    On libcurl 8.23.0: resource CURLHandle wraps *mut CURL with from curl_easy_init and drop curl_easy_cleanup, likewise the share pair; 21 of 100 functions presented (was 17). A program with no unsafe builds, makes an easy handle and drops it.

    Not done by this issue: setopt, perform, reset and the rest stay raw for #3124 (each reaches the program's debug callback through the fdebug field, which nothing declares). curl_multi_init is still unproven.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions