On Tue, 4 Jun 2024, Daniel Stenberg via curl-library wrote:

> Interesting case. I think we should make DoH requests exempt from that
> check/restriciton, as otherwise you can end up in this kind of catch-22
> situation.

kartatz, how about a patch like this?
 Thank you for the patch!

I checked out the latest master from GitHub and did a minimal curl build with 
CMake (-DHTTP_ONLY=ON) using OpenSSL as SSL backend.

Now the multi interface can resolve using DoH, but the program crashes as soon 
as it attempts to connect to the resolved address:

* Found bundle for host: 0x119dc60 [serially]
* Found bundle for host: 0x119dc60 [serially]
* Found bundle for host: 0x119dc60 [serially]
* Found bundle for host: 0x119dc60 [serially]
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Found bundle for host: 0x119dc60 [serially]
* No more connections allowed to host: 5
* No connections available.
* Host example.com:443 was resolved.
* IPv6: 2606:2800:21f:cb07:6820:80da:af6b:8b2c
* IPv4: 93.184.215.14
*   Trying 93.184.215.14:443...
* Hostname 'example.com' was found in DNS cache
[1]    15690 segmentation fault  ./main

I attached the gdb logs.

 
Starting program: /home/kartz/main 
Missing separate debuginfos, use: debuginfo-install glibc-2.17-326.el7_9.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7f5bb19 in start_connect (cf=0x457b50, 
    data=0x42a9d0, remotehost=0x0)
    at /home/kartz/curl/lib/connect.c:780
780         ai_family0 = remotehost->addr?
Missing separate debuginfos, use: debuginfo-install 
keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-55.el7_9.x86_64 
libcom_err-1.42.9-19.el7.x86_64 libselinux-2.5-15.el7.x86_64 
openssl-libs-1.0.2k-26.el7_9.x86_64 pcre-8.32-17.el7.x86_64 
zlib-1.2.7-21.el7_9.x86_64
#0  0x00007ffff7f5bb19 in start_connect (cf=0x457b50, 

    data=0x42a9d0, remotehost=0x0)
    at /home/kartz/curl/lib/connect.c:780
        ctx = 0x453320
        conn = 0x43f770
        result = CURLE_COULDNT_CONNECT
        ai_family0 = 0
        ai_family1 = 0
        timeout_ms = 294872
        addr0 = 0x3004012f0
        addr1 = 0x7ffff7f5c79b 
<cf_happy_eyeballs_create+149>
#1  0x00007ffff7f5c000 in cf_he_connect (cf=0x457b50, 

    data=0x42a9d0, blocking=false, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/connect.c:898
        ctx = 0x453320
        result = CURLE_OK
#2  0x00007ffff7f57f79 in Curl_conn_cf_connect 
(cf=0x457b50, 
    data=0x42a9d0, blocking=false, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/cfilters.c:307
No locals.
#3  0x00007ffff7f5c9ab in cf_setup_connect 
(cf=0x457b20, 
    data=0x42a9d0, blocking=false, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/connect.c:1199
        ctx = 0x43f390
        result = CURLE_OK
#4  0x00007ffff7f57f79 in Curl_conn_cf_connect 
(cf=0x457b20, 
    data=0x42a9d0, blocking=false, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/cfilters.c:307
No locals.
#5  0x00007ffff7f52014 in cf_hc_baller_connect 
(b=0x8e6978, 
    cf=0x8e87d0, data=0x42a9d0, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/cf-https-connect.c:135
        save = 0x0
#6  0x00007ffff7f52903 in cf_hc_connect (cf=0x8e87d0, 

    data=0x42a9d0, blocking=false, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/cf-https-connect.c:287
        ctx = 0x8e6920
        now = {tv_sec = 18162143, tv_usec = 989669}
        result = CURLE_OK
#7  0x00007ffff7f5810f in Curl_conn_connect 
(data=0x42a9d0, 
    sockindex=0, blocking=false, 
done=0x7fffffffdb8f)
    at /home/kartz/curl/lib/cfilters.c:353
        cf = 0x8e87d0
        result = CURLE_OK
#8  0x00007ffff7f8882d in multi_runsingle 
(multi=0x428220, 
    nowp=0x7fffffffdcc0, data=0x42a9d0)
    at /home/kartz/curl/lib/multi.c:2144
        stream_error = false
        msg = 0x0
        connected = false
        async = false
        protocol_connected = false
        dophase_done = false
        rc = CURLM_OK
        result = CURLE_OK
        recv_timeout_ms = 4500736
        send_timeout_ms = 989098
        control = 32767
#9  0x00007ffff7f89aa8 in curl_multi_perform (
    multi=0x428220, running_handles=0x7fffffffdd1c)
    at /home/kartz/curl/lib/multi.c:2776
        datanext = 0x42bcc0
        result = CURLM_OK
        nosig = false
        pipe_st = {old_pipe_act = {__sigaction_handler = {
              sa_handler = 0x0, sa_sigaction = 0x0}, 
            sa_mask = {__val = {0, 0, 0, 4491656, 0, 
                4199152, 140737488346688, 140737488345888, 
                140737349032493, 140737488345872, 
                140737353747854, 18162143, 988958, 18162144, 
                140733193494429, 140737488345920}}, 
            sa_flags = 67108864, 
            sa_restorer = 0x7ffff7a43400 <__restore_rt>}, 
          no_signal = false}
        data = 0x42a9d0
        returncode = CURLM_OK
        t = 0x7ffff7f89e89 <curl_multi_info_read+88>
        now = {tv_sec = 18162143, tv_usec = 989098}
#10 0x00000000004015e3 in main () at 
/home/kartz/test.c:35
        code = 0
        index = 15
        running = 23
        msg = 0x0
        left = 0
        curl = 0x426fd0
        curl_multi = 0x428220

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to