Skip to content
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

libcurl.dll x86_64 exception occasionally #69

Closed
lifeengines opened this issue Jun 3, 2024 · 3 comments
Closed

libcurl.dll x86_64 exception occasionally #69

lifeengines opened this issue Jun 3, 2024 · 3 comments

Comments

@lifeengines
Copy link

Has anyone encountered occasional exceptions with the libcurl.dll library in the Windows x86_64 version? Through debugging and analysis, it was found that in the function void Curl_resolver_cancel(struct Curl_easy *data) { destroy_async_data(&data->conn->resolve_async); }, the data->conn is already null. It seems that the following function is called twice:`/*

  • Curl_detach_connection() removes the given transfer from the connection.
  • This is the only function that should clear data->conn. This will
  • occasionally be called with the data->conn pointer already cleared.
    */
    void Curl_detach_connection(struct Curl_easy *data);`
    The comment within this function also indicates that there may be occasional multiple clearings of data->conn. In actual use, this occasionally triggers exceptions, and there is no 100% reproducible method found. However, after switching to using the c-ares library, the problem has not been observed so far.
@perklet
Copy link
Collaborator

perklet commented Jun 3, 2024

  • Does this behavior happen with the unpatched libcurl?
  • How do you switch to c-ares?

@lifeengines
Copy link
Author

lifeengines commented Jun 6, 2024

well,I do the test for unpatched libcurl,it's seems happen also.here is the exception shotscreen,the libcurl version is curl-8_5_0,same as curl-impersonate use.maybe this is a bug of libcurl.

无标题

I use msvc compiler,my compile command line is:

cmake .. -DZLIB_INCLUDE_DIR=../../zlib/ -DZLIB_LIBRARY=../../zlib/build/Debug/ -DUSE_NGHTTP2=ON -DNGHTTP2_INCLUDE_DIR=../../nghttp2/ -DNGHTTP2_LIBRARY=../../nghttp2/build/lib/Debug/ -DCURL_USE_OPENSSL=ON -DBUILD_STATIC_LIBS=ON -DBUILD_SHARED_LIBS=OFF -DCURL_ENABLE_SSL=ON -DCURL_DISABLE_INSTALL=OFF -DCURL_STATIC_CRT=ON -DENABLE_UNICODE=ON -DCURL_BROTLI=ON -DCURL_ZSTD=ON -DENABLE_IPV6=ON -DUSE_ECH=ON -DENABLE_WEBSOCKETS=ON -DBUILD_TESTING=OFF -DOPENSSL_INCLUDE_DIR=../../boringssl/include/ -DOPENSSL_CRYPTO_LIBRARY=../../boringssl/lib/ -DOPENSSL_ROOT_DIR=../boringssl/ -DBROTLI_INCLUDE_DIR=../../brotli/c/include/ -DBROTLIDEC_LIBRARY=../../brotli/lib/ -DBROTLICOMMON_LIBRARY=../../brotli/lib/ -DZstd_INCLUDE_DIR=../../zstd/include/ -DZstd_LIBRARY=../../zstd/static/

and the original release of curl-impersonate has the same exception even it's no symbol,I debugged,is't same exception position.
my usage of libcurl is simple,such as:

		curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
		curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
		curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
		curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);

		// Set lock and unlock callback functions
		curl_share_setopt(share, CURLSHOPT_LOCKFUNC, curl_lock);
		curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, curl_unlock);

and

		if (gCurlShare != nullptr)
			curl_easy_setopt(curl, CURLOPT_SHARE, gCurlShare);

nothing especially.
I just patched the original code:

void Curl_resolver_cancel(struct Curl_easy *data)
{
  destroy_async_data(&data->conn->resolve_async);
}

to:

void Curl_resolver_cancel(struct Curl_easy *data)
{
if (data->conn)
  destroy_async_data(&data->conn->resolve_async);
}

seems works fine.
but finally I add

-DENABLE_ARES=ON -DCARES_INCLUDE_DIR="../../c-ares/;../../c-ares/include/" -DCARES_LIBRARY=../../c-ares/lib/

to libcurl compile command line to force libcurl use c-ares to resolve DNS. seems works ok.

@perklet
Copy link
Collaborator

perklet commented Jun 6, 2024

The latest version of curl is 8.8.0, and I'm in the progress of upgrading curl-impersonate to be based on 8.7.1, see #67.

If this issue can be reproduced with 8.8.0, you might want to open an issue in the curl project.

@perklet perklet closed this as completed Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants