Skip to content

fix(curl): roll back duplicate MIME bookkeeping failures - #19861

Closed
DonRyuzaki wants to merge 2 commits into
boykopovar:mainfrom
DonRyuzaki:codex/curl-dupe-bookkeeping-20261114
Closed

DonRyuzaki wants to merge 2 commits into
boykopovar:mainfrom
DonRyuzaki:codex/curl-dupe-bookkeeping-20261114

Conversation

@DonRyuzaki

@DonRyuzaki DonRyuzaki commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Include copied MIME callback bookkeeping in the existing curl_easy_duphandle allocation rollback. A host allocation can fail after native duplication and registration, leaving an unreachable native handle and registry entry. Destroy that duplicate while callback owners remain live, then remove MIME bookkeeping and registration. Release the context mutex before copying ownership; retain the existing null result for host bad_alloc, the early guest-allocation exception control, and callback rebinding. If native cleanup itself throws, attempt bookkeeping removal once and propagate that callback exception.

Match the external C backend to the parent's MinGW DWARF exception mode. Its separate build previously emitted SEH metadata inside the DWARF wrapper module, aborting the unchanged early guest-calloc exception test on Windows. Only MINGW plus ANYPS5_MINGW_DWARF_EXCEPTIONS receives the matching C flags; the fixture and callback semantics are not suppressed.

Tested

Final base f9854b5a4b80a661ad6a5638565fc6d72a2f0a1a, head 9314260d7f33f0d49cc7417176a7d9d66215f79c, tree 8eb406dd0d6de4684904c4b827f50b4c5210d2f7.

  • Windows 11, bundled GCC 15.2, Release full configuration: built guest_curl, guest_curl_strings and all eight topic executables (Utility, Url, SlistMime, Options, Handles, Transfers, MimeCallback, Allocators). All 10 CTests pass, zero CTest skips, 2.12 seconds locally. Exact filter: ^guest_curl($|_(strings|utility|url|slistmime|options|handles|transfers|mimecallback|allocators)$) with ctest --no-tests=error --output-on-failure -V.
  • Reproduced the published dcc60dc8796bf5b837872f8ad9b2b6f2266863ac Windows allocator abort: unhandled GuestAllocationFailure, exit 0xc0000409. On that same base, changing only the three-line backend flags block makes the unchanged allocator test pass. The final rebased head above was separately rebuilt and tested across all ten suites.
  • Bundled GCC object probes confirm the selected -fexceptions -fno-asynchronous-unwind-tables -fno-unwind-tables combination emits DWARF CIE/FDE without SEH .pdata; an earlier -funwind-tables draft was rejected and is not in this PR.
  • Linux, Ubuntu 24.04 under WSL2, GCC 13.3, Release: cmake --build build --target libs guest_curl_Allocators_tests guest_curl_MimeCallback_tests guest_curl_Handles_tests guest_curl_Transfers_tests --parallel 8 passes; ctest --test-dir build --no-tests=error --output-on-failure -R '^guest_curl_(allocators|mimecallback|handles|transfers)$': 4/4 pass, zero skips.
  • Fresh test-only baseline fb5d4e2023892a094daaf8bede9eafb5ffa7481d reproduces the registered duplicate bookkeeping failure; the other selected suites pass. The Linux host-new fault requires a captured native duplicate matching its source size and a successful CURLOPT_PRIVATE probe proving it is already registered. Original-MIME and clone-of-clone cases restore exact guest allocation maps, release copied callback data once and permit retry.
  • Host-new interposition is Linux-only. Windows executes the early guest-calloc exception control and ordinary ownership/lifecycle cases; no Windows late host-new interposition result is claimed. Arbitrary native C cleanup callbacks that refuse to complete do not acquire a leak-free guarantee.
  • Full branch checking requires manual comparison of feat(libcurl): implement curl_formget #17661, feat(libcurl): implement curl_formadd #17667 and feat(libcurl): implement curl_m[v]fprintf and curl_m[v]printf #18468. Exact heads, merge bases and complete shared-file hashes match the fully read current precheck, including feat(libcurl): implement curl_m[v]fprintf and curl_m[v]printf #18468's newly shared CMake registrations. They change legacy formget/formadd/format adapters, without this transaction or backend exception policy. No functional dependency found. This is a manual assessment, not a clean automated result.
  • No game, GPU or console-hardware execution is claimed.
  • Configured with BUILD_TESTING=ON, FT_ENABLE_ERROR_STRINGS=OFF, CMAKE_LINK_DEPENDS_NO_SHARED=ON. Conventions and literal git diff --check pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

@github-actions github-actions Bot added the prx label Nov 14, 2026
@JJenkx

JJenkx commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Windows check of head dcc60dc879, merged onto main 3c620812fb (f107793acd, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.

  • guest_curl, guest_curl_strings pass in 3 of 3 runs, none skipped.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 17661 core/libs/prx/libcurl/Export.cpp
PR 17667 core/libs/prx/libcurl/Export.cpp
PR 18468 core/libs/prx/libcurl/CMakeLists.txt
core/libs/prx/libcurl/Export.cpp

@DonRyuzaki
DonRyuzaki force-pushed the codex/curl-dupe-bookkeeping-20261114 branch from dcc60dc to 9314260 Compare November 14, 2026 07:22
@github-actions github-actions Bot added the build label Nov 14, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@DonRyuzaki I am closing this as padding. It rolls back libcurl's duplicate MIME bookkeeping when it fails, a path no title reaches, and the same kind of change has been sent for many libraries, so we are not taking this series. If a game hits a real leak, a PR for that case with the title and the run that shows it is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants