<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>287815</bug_id>
          
          <creation_ts>2025-02-17 13:11:37 -0800</creation_ts>
          <short_desc>[curl] LibreSSL SSL_read: Connection closed abruptly, errno 0 (Fatal because this is a curl debug build)</short_desc>
          <delta_ts>2025-02-18 16:17:28 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Platform</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>DoNotImportToRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Fujii Hironori">fujii</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2095242</commentid>
    <comment_count>0</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-17 13:11:37 -0800</bug_when>
    <thetext>If I use a debug build of libcurl.dll, some https tests fail.
For example,

  http/wpt/service-workers/check-service-worker-header.https.html [ Failure ]
  imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub.html [ Failure ]
  imported/w3c/web-platform-tests/urlpattern/urlpattern.https.any.worker.html [ Failure ]

If I open https://localhost:9443/WebKit/service-workers/check-service-worker-header.https.html with Windows MiniBrowser,
the following message was reported on the debug console.

&gt; LibreSSL SSL_read: Connection closed abruptly, errno 0 (Fatal because this is a curl debug build)

To use a debug build of libcurl.dll, copy libcurl.dll and zlib1.dll from WebKitLibraries/win/debug/bin directory to WebKitLibraries/win/bin or WebKitBuild/Debug/bin directories.

However, due to another libcurl bug bug#286788, libcurl is going to abort quickly now. You need to compile libcurl with the DEBUGASSERT(NULL) commented out.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095273</commentid>
    <comment_count>1</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-17 14:23:14 -0800</bug_when>
    <thetext>curl.exe also reports an error.

&gt; curl.exe -k https://localhost:9443/WebKit/service-workers/check-service-worker-header.https.html
&gt; (...)
&gt; curl: (56) Failure when receiving data from the peer</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095340</commentid>
    <comment_count>2</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-17 17:00:50 -0800</bug_when>
    <thetext>This is the code of &quot;Fatal because this is a curl debug build&quot;.
https://github.com/curl/curl/blob/61f85bf9678952039efc220591a264620909ac5d/lib/vtls/openssl.c#L5217-L5242

This seems to be curl&apos;s intention.
https://github.com/curl/curl/issues?q=is%3Aissue%20%22Fatal%20because%20this%20is%20a%20curl%20debug%20build%22%20
https://github.com/curl/curl/issues/15669#issuecomment-2514419251</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095341</commentid>
    <comment_count>3</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-17 17:02:23 -0800</bug_when>
    <thetext>CurlRequestScheduler::completeTransfer gets CURLE_OK with a release build of libcurl.dll, but CURLE_RECV_ERROR with a debug build.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095415</commentid>
    <comment_count>4</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-17 23:55:24 -0800</bug_when>
    <thetext>I use this patch to dump libcurl debug log to the debug console.

diff --git a/Source/WebCore/platform/network/curl/CurlRequest.cpp b/Source/WebCore/platform/network/curl/CurlRequest.cpp
index 950dbeadadf1..3f0dd3d0c481 100644
--- a/Source/WebCore/platform/network/curl/CurlRequest.cpp
+++ b/Source/WebCore/platform/network/curl/CurlRequest.cpp
@@ -512,6 +512,7 @@ int CurlRequest::didReceiveDebugInfo(curl_infotype type, std::span&lt;const char&gt; d
 {
     if (!data.data())
         return 0;
+    OutputDebugStringA(data.data());
 
     if (type == CURLINFO_HEADER_OUT) {
         String requestHeader(data);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095560</commentid>
    <comment_count>5</comment_count>
      <attachid>474276</attachid>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-18 13:20:54 -0800</bug_when>
    <thetext>Created attachment 474276
workaround patch for libcurl 8.12.1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095644</commentid>
    <comment_count>6</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-18 15:52:08 -0800</bug_when>
    <thetext>Run wpt server by invoking &quot;python wpt.py serve&quot; in another terminal.
If I specify a pipe, the error doesn&apos;t happen.

&gt; PS C:\&gt; curl --no-progress-meter -ko NUL https://web-platform.test:8443/acid/README.md
&gt; curl: (56) Failure when receiving data from the peer
&gt; PS C:\&gt; curl --no-progress-meter -ko NUL https://web-platform.test:8443/acid/README.md?pipe=sub</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2095657</commentid>
    <comment_count>7</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2025-02-18 16:17:28 -0800</bug_when>
    <thetext>This is a workaround patch.

diff --git a/LayoutTests/imported/w3c/web-platform-tests/tools/wptserve/wptserve/handlers.py b/LayoutTests/imported/w3c/web-platform-tests/tools/wptserve/wptserve/handlers.py
index 62faf47d6456..5b302f03bb54 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/tools/wptserve/wptserve/handlers.py
+++ b/LayoutTests/imported/w3c/web-platform-tests/tools/wptserve/wptserve/handlers.py
@@ -243,7 +243,7 @@ class FileHandler:
         &quot;&quot;&quot;Return either the handle to a file, or a string containing
         the content of a chunk of the file, if we have a range request.&quot;&quot;&quot;
         if byte_ranges is None:
-            return open(path, &apos;rb&apos;)
+            return open(path, &apos;rb&apos;).read()
         else:
             with open(path, &apos;rb&apos;) as f:
                 response.status = 206</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>474276</attachid>
            <date>2025-02-18 13:20:54 -0800</date>
            <delta_ts>2025-02-18 13:20:54 -0800</delta_ts>
            <desc>workaround patch for libcurl 8.12.1</desc>
            <filename>curl.patch</filename>
            <type>text/plain</type>
            <size>1032</size>
            <attacher name="Fujii Hironori">fujii</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL2xpYi9tdWx0aS5jIGIvbGliL211bHRpLmMKaW5kZXggMmIwNWU5NGEwLi5l
MDk5MDRmZjcgMTAwNjQ0Ci0tLSBhL2xpYi9tdWx0aS5jCisrKyBiL2xpYi9tdWx0aS5jCkBAIC0z
MDkxLDcgKzMwOTEsNyBAQCBDVVJMTWNvZGUgQ3VybF9tdWx0aV9wb2xsc2V0X2V2KHN0cnVjdCBD
dXJsX211bHRpICptdWx0aSwKICAgICAgICAgLyogc3RpbGwgdXNlcnMsIGJ1dCByZW1vdmUgdGhp
cyBoYW5kbGUgYXMgYSB1c2VyIG9mIHRoaXMgc29ja2V0ICovCiAgICAgICAgIGlmKEN1cmxfaGFz
aF9kZWxldGUoJmVudHJ5LT50cmFuc2ZlcnMsIChjaGFyICopJmRhdGEsCiAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgc2l6ZW9mKHN0cnVjdCBDdXJsX2Vhc3kgKikpKSB7Ci0gICAgICAgICAg
REVCVUdBU1NFUlQoTlVMTCk7CisgICAgICAgICAgLy9ERUJVR0FTU0VSVChOVUxMKTsKICAgICAg
ICAgfQogICAgICAgfQogICAgIH0KZGlmZiAtLWdpdCBhL2xpYi92dGxzL29wZW5zc2wuYyBiL2xp
Yi92dGxzL29wZW5zc2wuYwppbmRleCA2ZGVkNWYzYzAuLmUwZTVkMmMxMyAxMDA2NDQKLS0tIGEv
bGliL3Z0bHMvb3BlbnNzbC5jCisrKyBiL2xpYi92dGxzL29wZW5zc2wuYwpAQCAtNTIyOSw3ICs1
MjI5LDcgQEAgc3RhdGljIHNzaXplX3Qgb3NzbF9yZWN2KHN0cnVjdCBDdXJsX2NmaWx0ZXIgKmNm
LAogICAgICAgICAgV2UgY2FuIHVzZSB0aGlzIHRvIGdhdWdlIGhvdyBtYW55IHVzZXJzIG1heSBi
ZSBhZmZlY3RlZCwgYW5kCiAgICAgICAgICBpZiBpdCBnb2VzIG9rIGV2ZW50dWFsbHkgdHJhbnNp
dGlvbiB0byBhbGxvdyBpbiBkZXYgYW5kIHJlbGVhc2Ugd2l0aAogICAgICAgICAgdGhlIG5ld2Vz
dCBPcGVuU1NMOiAjaWYgKE9QRU5TU0xfVkVSU0lPTl9OVU1CRVIgPj0gMHgxMDEwMTAwMEwpICov
Ci0jaWZkZWYgREVCVUdCVUlMRAorI2lmIDAKICAgICAgIGlmKGVyciA9PSBTU0xfRVJST1JfU1lT
Q0FMTCkgewogICAgICAgICBpbnQgc29ja2VyciA9IFNPQ0tFUlJOTzsKICAgICAgICAgaWYoc29j
a2VycikK
</data>

          </attachment>
      

    </bug>

</bugzilla>