Skip to content

CURLE_BAD_FUNCTION_ARGUMENT when calling HTTPS URLs using curl v>=8.12.1 #6535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sushshring opened this issue Apr 22, 2025 · 1 comment · May be fixed by #6537
Open

CURLE_BAD_FUNCTION_ARGUMENT when calling HTTPS URLs using curl v>=8.12.1 #6535

sushshring opened this issue Apr 22, 2025 · 1 comment · May be fixed by #6537
Assignees
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@sushshring
Copy link

Describe the bug
CURL returns CURLE_BAD_FUNCTION_ARGUMENT when a call is made to any HTTPS URL. This error started appearing after curl versions 8.12, which suggests some of the new changes to how CURL is doing SSL caching needs an update to downstream consumers.

Exception or Stack Trace

Unhandled exception at 0x00007FFC4AA0933A in azure-sdk-for-cpp-testing.exe: Microsoft C++ exception: Azure::Core::Http::TransportException at memory location 0x0000007F7C7FE430.
>	libcurl-d.dll!schannel_connect(Curl_cfilter * cf, Curl_easy * data, bool * done) Line 1676	C
 	libcurl-d.dll!schannel_recv(Curl_cfilter * cf, Curl_easy * data, char * buf, unsigned __int64 len, CURLcode * err) Line 2071	C
 	libcurl-d.dll!ssl_cf_recv(Curl_cfilter * cf, Curl_easy * data, char * buf, unsigned __int64 len, CURLcode * err) Line 1530	C
 	libcurl-d.dll!Curl_cf_def_recv(Curl_cfilter * cf, Curl_easy * data, char * buf, unsigned __int64 len, CURLcode * err) Line 112	C
 	libcurl-d.dll!Curl_cf_def_recv(Curl_cfilter * cf, Curl_easy * data, char * buf, unsigned __int64 len, CURLcode * err) Line 112	C
 	libcurl-d.dll!Curl_cf_recv(Curl_easy * data, int num, char * buf, unsigned __int64 len, CURLcode * code) Line 250	C
 	libcurl-d.dll!Curl_conn_recv(Curl_easy * data, int sockindex, char * buf, unsigned __int64 blen, __int64 * n) Line 917	C
 	libcurl-d.dll!curl_easy_recv(void * d, void * buffer, unsigned __int64 buflen, unsigned __int64 * n) Line 1271	C
 	azure-core.dll!Azure::Core::Http::CurlConnection::ReadFromSocket(unsigned char * buffer, unsigned __int64 bufferSize, const Azure::Core::Context & context) Line 1117	C++
 	azure-core.dll!Azure::Core::Http::CurlSession::ReadStatusLineAndHeadersFromRawResponse(const Azure::Core::Context & context, bool reuseInternalBuffer) Line 855	C++
 	azure-core.dll!Azure::Core::Http::CurlSession::Perform(const Azure::Core::Context & context) Line 470	C++
 	azure-core.dll!Azure::Core::Http::CurlTransport::Send(Azure::Core::Http::Request & request, const Azure::Core::Context & context) Line 363	C++
 	azure-sdk-for-cpp-testing.exe!main() Line 15	C++
 	azure-sdk-for-cpp-testing.exe!invoke_main() Line 79	C++
 	azure-sdk-for-cpp-testing.exe!__scrt_common_main_seh() Line 288	C++
 	azure-sdk-for-cpp-testing.exe!__scrt_common_main() Line 331	C++
 	azure-sdk-for-cpp-testing.exe!mainCRTStartup(void * __formal) Line 17	C++
 	kernel32.dll!BaseThreadInitThunk() + 23 bytes	Unknown
 	ntdll.dll!RtlUserThreadStart() + 44 bytes	Unknown

To Reproduce

int main()
{
    std::string url{ "https://www.bing.com" };
    auto http_request = Azure::Core::Http::Request{ Azure::Core::Http::HttpMethod::Get, Azure::Core::Url {url} };

    Azure::Core::Http::CurlTransport transport{};
    auto response = transport.Send(http_request, Azure::Core::Context{});
    auto body_vec = response->ExtractBodyStream()->ReadToEnd();

    std::cout << "Finished" << std::endl;
    return 0;
}

with curl version >= 8.12.1
Code Snippet

for (CURLcode readResult = CURLE_AGAIN; readResult == CURLE_AGAIN;)
{
  readResult = curl_easy_recv(m_handle.get(), buffer, bufferSize, &readBytes);
  switch (readResult)
  {
    case CURLE_AGAIN: {
      // start polling operation
      auto pollUntilSocketIsReady = pollSocketUntilEventOrTimeout(
          context, m_curlSocket, PollSocketDirection::Read, 60000L);

      if (pollUntilSocketIsReady == 0)
      {
        throw TransportException("Timeout waiting for socket to read.");
      }
      else if (pollUntilSocketIsReady < 0)
      { // negative value, error while polling
        throw TransportException("Error while polling for socket ready read");
      }

      // Ready to continue download.
      break;
    }
    case CURLE_OK: {
      break;
    }
    default: {
      // Error reading from socket
      throw TransportException(
          "Error while reading from network socket. CURLE code: " + std::to_string(readResult)
          + ". " + std::string(curl_easy_strerror(readResult)));
    }
  }
}

Expected behavior
No error

Screenshots

Setup (please complete the following information):

  • OS: Windows 11 25H2
  • IDE : Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.13.6
  • Version of the Library used: 1.15

Additional context
Add any other context about the problem here.

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • [x ] Bug Description Added
  • [x ] Repro Steps Added
  • [x ] Setup information Added
@github-actions github-actions bot added Azure.Core Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Apr 22, 2025
Copy link

Thank you for your feedback. Tagging and routing to the team member best able to assist.

@sushshring sushshring linked a pull request Apr 23, 2025 that will close this issue
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants