termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.22k stars 3.04k forks source link

[Bug]: libcurl domain resolution fails since the enabling of c-ares support #21727

Closed marcprux closed 1 day ago

marcprux commented 3 weeks ago

Problem description

A program linking to libcurl 8.10.1-1 fails to resolve domain names, whereas it worked fine with 8.9.1. This new failure seems to correlate with the addition of the c-ares dependency in https://github.com/termux/termux-packages/pull/21686.

What steps will reproduce the bug?

My test case is using a Swift program whose FoundationNetworking library uses libcurl for networking. Getting the exact same setup is somewhat involved without installing the entire Swift toolchain (see https://github.com/finagolfin/swift-android-sdk/pull/178). I could probably whip up a C program that reproduces it if necessary.

The output of my test program with curl debugging enabled is:

zap swift-projects/demo % ANDROID_SERIAL=19091FDF600BAY skip android run --env URLSessionDebugLibcurl=YES --env URLSessionDebug=YES demo "http://www.example.com/"
Building for debugging...
[0/3] Write swift-version--5366198ACE037756.txt
Build complete! (0.18s)
[✓] Check Swift Package (0.19s)
[✓] Connecting to Android (0.05s)
[✓] Copying executable files (1.05s)
[1]                   Could not resolve host: www.example.com␊
[1]                   Could not resolve host: www.example.com␊
[1]                   closing connection #0␊
Connecting to: http://www.example.com/
Error: Error Domain=NSCocoaErrorDomain Code=256 "(null)"

What is the expected behavior?

No response

System information

This is an issue with the termux libraries, not with termux itself. 

The respective libraries are libcurl_8.10.1-1_aarch64, c-ares_1.33.1_aarch64, libnghttp2_1.63.0_aarch64, libnghttp3_1.6.0_aarch64, libssh2_1.11.0_aarch64, openssl_1:3.3.2_aarch64, and zlib_1.3.1_aarch64
licy183 commented 3 weeks ago

I'm not sure whether this is a regression of libcurl or some bug of swift. If possible, please provide a C program that reproduces this issue.

uahim commented 2 weeks ago

this also seems to affect curl and, more importantly, pkg upgrade on my termux which then claims all repos are bad. it is reproducible and can only be fixed by termux-reset. before curl 8.10.1-1 and libcurl 8.10.1-1 and c-ares were installed two days ago, everything worked fine.

I can provide further info if needed.

edit: by this I mean domain resolution fails, e.g. curl github.com produces a timeout error

licy183 commented 2 weeks ago

Can you check if the dns specified in $PREFIX/etc/resolv.conf (default is 8.8.8.8 or 8.8.4.4) is blocked by your ISP? Thanks!

uahim commented 2 weeks ago

check if the dns specified in $PREFIX/etc/resolv.conf (default is 8.8.8.8 or 8.8.4.4) is blocked by your ISP?

that was it. changing the nameservers in this file fixes it for me. thank you.

gensx-x1 commented 2 days ago

Problem description

A program linking to libcurl 8.10.1-1 fails to resolve domain names, whereas it worked fine with 8.9.1. This new failure seems to correlate with the addition of the c-ares dependency in #21686.

What steps will reproduce the bug?

My test case is using a Swift program whose FoundationNetworking library uses libcurl for networking. Getting the exact same setup is somewhat involved without installing the entire Swift toolchain (see finagolfin/swift-android-sdk#178). I could probably whip up a C program that reproduces it if necessary.

The output of my test program with curl debugging enabled is:

zap swift-projects/demo % ANDROID_SERIAL=19091FDF600BAY skip android run --env URLSessionDebugLibcurl=YES --env URLSessionDebug=YES demo "http://www.example.com/"
Building for debugging...
[0/3] Write swift-version--5366198ACE037756.txt
Build complete! (0.18s)
[✓] Check Swift Package (0.19s)
[✓] Connecting to Android (0.05s)
[✓] Copying executable files (1.05s)
[1]                   Could not resolve host: www.example.com␊
[1]                   Could not resolve host: www.example.com␊
[1]                   closing connection #0␊
Connecting to: http://www.example.com/
Error: Error Domain=NSCocoaErrorDomain Code=256 "(null)"

What is the expected behavior?

No response

System information

This is an issue with the termux libraries, not with termux itself. 

The respective libraries are libcurl_8.10.1-1_aarch64, c-ares_1.33.1_aarch64, libnghttp2_1.63.0_aarch64, libnghttp3_1.6.0_aarch64, libssh2_1.11.0_aarch64, openssl_1:3.3.2_aarch64, and zlib_1.3.1_aarch64

i had very similar issue, and there is already temporary solution , check it here #21987

marcprux commented 1 day ago

Note that I'm encountering this issue in an Android apk that embeds Termux's libcurl.so, so any solution that involves editing /etc/resolv.conf won't be possible for end users of the app.

Hoping this will be fixed by https://github.com/termux/termux-packages/pull/21988.