# libcurl technical debt ### Functional - [Version and backend](../../../core/libs/prx/libcurl/CMakeLists.txt) - the exact console version and Sony patches are unknown. The export set matches upstream 7.73 through 7.85. The source is curl tag `curl-7_81_0` (its checked-in version string includes `7.81.0-DEV`), using bundled mbedtls 3.6.7 and nghttp2. The configuration enables FILE, HTTP and HTTPS, static linking, IPv6 and the threaded resolver. Other protocols, TLS backends, LDAP, SSH, compression libraries, IDN, GSSAPI, QUIC and external packages are disabled. `MBEDTLS_ALLOW_PRIVATE_ACCESS` permits curl's backend to access the bundled mbedtls fields; the existing mbedtls target's configuration definitions are forwarded to curl. - [Guest layouts](../../../core/libs/prx/libcurl/include/CurlTypes.hpp) - console structure definitions remain unverified. Mirrors use x86-64 SysV LP64 sizes and offsets from curl 7.81.0. Matching host layouts for lists, option descriptors, messages and backend descriptors are asserted before sharing their pointers. Version information and timeout outputs widen host long fields. This does not establish console-specific ABI extensions. - [Allocator callbacks](../../../core/libs/prx/libcurl/Export.cpp) - console allocator ABI and failure behavior remain unverified. Default allocation uses the guest libc heap; custom SysV callbacks follow pinned [curl 7.81.0 easy.c](https://github.com/curl/curl/blob/801bd5138ce31aa0d906fa4e2eabfc599d74e793/lib/easy.c#L135-L302). Callback code and its heap must outlive all associated objects, including allocations released after global cleanup. Caller-invalid pointers, reentrant global lifecycle calls from allocator callbacks, concurrent allocator replacement and mixing allocation families are not validated. - [Environment](../../../core/libs/prx/libcurl/Export.cpp) - internal curl proxy and configuration lookups still consult the host environment. Console environment behavior and allocation sequence remain unverified. The exported accessor copies the guest libc value through the active strdup callback on both hosts; pinned [curl 7.81.0 getenv.c](https://github.com/curl/curl/blob/801bd5138ce31aa0d906fa4e2eabfc599d74e793/lib/getenv.c) uses strdup on POSIX and realloc with GetEnvironmentVariableA on Windows. - [Resolver thread](../../../core/libs/prx/libcurl/CMakeLists.txt) - libcurl is built with its threaded resolver (c-ares is off), so `getaddrinfo_thread` runs on a host thread libcurl creates and allocates and fills the `Curl_addrinfo` results through the guest heap (`lib/curl_addrinfo.c`). That thread is not a guest thread and writes guest memory outside any guest call. Closes when: name resolution runs on a guest-visible thread or through the console resolver. - [Native callback objects](../../../core/libs/prx/libcurl/Export.cpp) - `CURLOPT_SSL_CTX_FUNCTION` and `SSL_CTX_DATA` throw `std::invalid_argument` naming the option because mbedtls context objects belong to the host. The three `CURLOPT_CONV_*_FUNCTION` options throw the same exception because this build has no conversion backend. TLS session/SSL pointer getinfo results expose host mbedtls internals only as opaque pointers; guest code cannot operate on them. - [Guest long](../../../core/libs/prx/libcurl/Export.cpp) - LONG easy/multi values outside the host long range throw `std::out_of_range` on LLP64 hosts. Chunk callback long return values have the same restriction. `CURLOPT_HTTPPOST` throws `std::invalid_argument` on LLP64 because legacy LP64 form nodes have no host layout adapter. - [Socket ownership](../../../core/libs/prx/libcurl/src/CurlSockets.cpp) - console callback ABI and error behavior remain unverified. Borrowed descriptors use kernel-owned duplicates; callback code and close DATA must outlive pooled connections. Unix address reporting retains the kernel unnamed-pair layout. Native mode transitions follow [nonblock.c](https://github.com/curl/curl/blob/801bd5138ce31aa0d906fa4e2eabfc599d74e793/lib/nonblock.c#L43-L89); resolver removal follows [asyn-thread.c](https://github.com/curl/curl/blob/801bd5138ce31aa0d906fa4e2eabfc599d74e793/lib/asyn-thread.c#L380-L419). Non-socket extra descriptors on Windows, virtual extra descriptors and failed descriptor leases throw. Closes when: guest descriptor waits integrate with native curl wakeups, lease failures have verified curl results, and console socket/address behavior is measured. - [Push ownership](../../../core/libs/prx/libcurl/Export.cpp) - `CURLMOPT_PUSHFUNCTION` and `PUSHDATA` throw through `NotImplemented_nid_no_patch`. In curl 7.81.0 `http2.c:push_promise`, an accepted pushed handle can be closed internally if `Curl_multi_add_perform` fails. The adapter has no destruction notification for releasing that handle's copied callback context. Timer callbacks and scalar multi options are adapted. Closes when: native easy-handle destruction notifies the adapter for internally rejected pushes. - [MIME callbacks](../../../core/libs/prx/libcurl/Export.cpp) - whether the console calls the `curl_mime_data_cb` free function again for each copy `curl_easy_duphandle` makes, as curl 7.81.0 `Curl_mime_duppart` does, is unverified. The guest functions are called through a host context shared by the part and its copies; it is released once the part's content is replaced or its mime freed and every handle holding a copy is reset, cleaned up or given another `CURLOPT_MIMEPOST`. The adapter learns this from the mime, part and easy exports, so a part freed outside them is not seen; in 7.81.0 only `curl_easy_duphandle` copies parts. - [Default stdio streams](../../../core/libs/prx/libcurl/Export.cpp) - with the default callbacks, a NULL `WRITEDATA` ends the transfer with `CURLE_WRITE_ERROR` and a NULL `READDATA` with `CURLE_ABORTED_BY_CALLBACK`, where libcurl would pass NULL to `fwrite` or `fread`. A rewind of the default input returns `CURL_SEEKFUNC_CANTSEEK` when guest `fseek` fails or the stream is NULL; a rewind of a `/dev/random` or `/dev/urandom` stream throws `std::runtime_error` through libcurl's frames. Native `Curl_readrewind` identifies its default input by comparing the read function to host fread. The guest default read trampoline needs an internal seek callback instead; successful rewinds use guest fseek, but a failed rewind cannot reproduce the native diagnostic path through that callback. - [Transfer scope](../../../core/libs/prx/libcurl/Export.cpp) - HTTP/HTTPS transfers, HSTS callbacks, disabled protocol callbacks and asynchronous native writes into guest buffers remain unverified. File URLs use the host filesystem and Windows file URL normalization rather than a guest path namespace. Verbose bytes use guest fwrite; the built-in progress meter writes the native stream underlying STDERR, without guest FileStream state updates. The standalone harness substitutes guest stdio operations and does not verify arena protection or full libc integration. - [Formatting](../../../core/libs/prx/libcurl/src/CurlFormat.cpp) - `curl_m[v]snprintf`, `curl_m[v]sprintf`, `curl_m[v]aprintf`, `curl_m[v]fprintf` and `curl_m[v]printf` follow `lib/mprintf.c` of curl 7.81.0 with LP64 argument sizes and without the Windows `I32` and `I64` qualifiers, and format floating-point conversions through the guest `snprintf` instead of the console `sprintf`. Their digits are those of the `%e, %f and %g` entry of [libc](libc.md), which the console's curl also gets from `libc.prx`, so they differ from a host build of curl on exact ties and past 17 significant digits (`%.0f` of 2.5 is `3` here and `2` in a Windows host build). Formats whose behaviour there is undefined throw instead: an argument position no conversion describes, more than 128 conversions, a floating-point result longer than the 326-byte work buffer and a `%n` destination that is not writable guest memory. Console output is unverified. Labels: console, tested - [`curl_formfree`](../../../core/libs/prx/libcurl/src/FormFree.cpp) - the guest node layout is the unverified LP64 mirror of curl 7.81.0's `struct curl_httppost`, and nodes are released through the guest heap described under Allocator. Adapted from [lib/formdata.c](https://github.com/curl/curl/blob/801bd5138ce31aa0d906fa4e2eabfc599d74e793/lib/formdata.c#L746-L771): it frees each node of the `next` chain after its `more` chain, keeping names marked `CURL_HTTPPOST_PTRNAME` and contents marked `PTRCONTENTS`, `BUFFER` or `CALLBACK`. ### Unimplemented exports - [`curl_formadd`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: LP64 form nodes and length options are not translated to LLP64 host forms. - [`curl_formget`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: LP64 form nodes and length options are not translated to LLP64 host forms. - [`curl_global_init_mem`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: Allocator callback ownership across repeated initialization and cleanup is not adapted exactly. - [`curl_mime_data_cb`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: Curl_mime_duppart copies the same callback argument and free function without a duplication hook. Per-part guest callback contexts cannot be copied and freed with exact ownership across duplicates; no adapter is installed. - [`curl_multi_assign`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: The guest registry lacks reverse lookup and borrowed-owner installation for curl-owned sockets; see Socket ownership above. - [`curl_multi_fdset`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: The guest registry lacks reverse lookup and borrowed-owner installation for curl-owned sockets; see Socket ownership above. - [`curl_multi_socket`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: The guest registry lacks reverse lookup and borrowed-owner installation for curl-owned sockets; see Socket ownership above. - [`curl_multi_socket_action`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: The guest registry lacks reverse lookup and borrowed-owner installation for curl-owned sockets; see Socket ownership above. - [`curl_maprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mfprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_msnprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_msprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mvaprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mvfprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mvprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mvsnprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter. - [`curl_mvsprintf`](../../../core/libs/prx/libcurl/Export.cpp) - throws through `NotImplemented_nid_no_patch`: SysV variadic formatting with LP64 long and %ln writes and guest FILE streams has no exact adapter.