Skip to content

curl --version spends 5 seconds waiting for OpenLDAP #23651

Closed

Description

@LukasGelbmann

I did this

I installed curl on macOS using homebrew and ran curl --version. It takes 5 seconds each time I run it.

% time /opt/homebrew/opt/curl/bin/curl --version
curl 8.23.0 (aarch64-apple-darwin25.6.0) libcurl/8.23.0 OpenSSL/4.1.0 zlib/1.2.12 brotli/1.2.1 zstd/1.5.7 AppleIDN libpsl/0.23.3 libssh2/1.11.1 nghttp2/1.70.0 ngtcp2/1.25.0 nghttp3/1.18.0 mit-krb5/1.7-prerelease OpenLDAP/2.4.28/Apple
Release-Date: 2026-10-14
[...]
/opt/homebrew/opt/curl/bin/curl --version  0.02s user 0.02s system 0% cpu 5.048 total

It looks like it hangs here:

Curl_ldap_version (curl/lib/ldap.c or curl/lib/openldap.c)
-> ldap_get_option (OpenLDAP/libraries/libldap/options.c [1])
-> dispatch_once_f -> [...] -> ldap_int_init_global_opts (OpenLDAP/libraries/libldap/init.c [2])
-> ldap_int_initialize
-> ldap_pvt_get_fqdn (OpenLDAP/libraries/libldap/util-int.c [3])
-> ldap_pvt_gethostbyname_a
-> gethostbyname
-> does a DNS query that hangs for 5 seconds

[1] https://github.com/apple-oss-distributions/OpenLDAP/blob/OpenLDAP-556/OpenLDAP/libraries/libldap/options.c
[2] https://github.com/apple-oss-distributions/OpenLDAP/blob/OpenLDAP-556/OpenLDAP/libraries/libldap/init.c
[3] https://github.com/apple-oss-distributions/OpenLDAP/blob/OpenLDAP-556/OpenLDAP/libraries/libldap/util-int.c

For a previous report of the same issue, see #8057. There is a little bit of discussion there.

I expected the following

I expected curl --version to complete in a fraction of a second.

curl/libcurl version

curl 8.23.0, see above

operating system

Darwin MacBook[...]

Activity

  1. self-assigned this
    on Oct 28, 2026
  2. icing commented on Oct 28, 2026

    @icing
    Contributor

    Not that I do not believe you, just to add some data:

    > time /usr/local/opt/curl/bin/curl -V
    curl 8.23.0 (x86_64-apple-darwin25.6.0) libcurl/8.23.0 OpenSSL/4.0.3 zlib/1.2.12 brotli/1.2.0 zstd/1.5.7 AppleIDN libpsl/0.23.3 libssh2/1.11.1 nghttp2/1.70.0 ngtcp2/1.25.0 nghttp3/1.18.0 mit-krb5/1.7-prerelease OpenLDAP/2.4.28/Apple
    Release-Date: 2026-10-14
    Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt mqtts pop3 pop3s rtsp scp sftp smtp smtps telnet tftp ws wss
    Features: alt-svc AppleSecTrust AsynchDNS brotli GSS-API HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Kerberos Largefile libz PSL SPNEGO SSL threadsafe UnixSockets zstd
    
    real	0m0.036s
    user	0m0.019s
    sys	0m0.012s
  3. vszakats commented on Oct 28, 2026

    @vszakats
    Member

    Thanks for the report. Interesting! I wonder why it doesn't happen on
    my machine to catch this earlier. Also not seen in CI, e.g.:
    https://github.com/curl/curl/actions/runs/40692850852/job/122831844001#step:13:23

    Because the version number returned so far in all known macOS versions
    was the same, here's a PR dropping this query and returning AppleLDAP
    instead: #23652. Upside is that it makes it easier to refer to this
    backend, which uses the "legacy" LDAP curl interface, not the OpenLDAP
    one.

    The static version number is unimportant from a users/dev POV, and only
    reflects the upstream OpenLDAP version that Apple forked way back. If
    this changes in the future, we can revisit and add some kind of version.

  4. LukasGelbmann commented on Oct 28, 2026

    @LukasGelbmann
    Author

    It's not normal for gethostbyname() with the machine's own hostname to hang for 5 seconds. #8057 indicates that it happened to at least one other person before. I haven't investigated why it does that, surely it's unrelated to curl.

    But regardless of that specific symptom, I think the issue is it's not good that curl --version can possibly do network queries (DNS). Arguably OpenLDAP's flaw, but still ends up being a problem in curl.

  5. vszakats commented on Oct 28, 2026

    @vszakats
    Member
    But regardless of that specific symptom, I think the issue is it's not good that `curl --version` can possibly do network queries (DNS). Arguably OpenLDAP's flaw, but still ends up being a problem in `curl`.
    

    It isn't good, I agree. No unexpected/unwarranted network request is good IMO, regardless of the time it takes.

  6. LukasGelbmann commented on Oct 28, 2026

    @LukasGelbmann
    Author

    Looks like the flaw was fixed on upstream (non-Apple) OpenLDAP in 2025: https://bugs.openldap.org/show_bug.cgi?id=10297

    I think that indicates that the issue is already fixed on non-Apple platforms, as long as you're on a fairly new version of OpenLDAP (2.7.0+).

  7. added a commit that references this issue on Oct 28, 2026
    7f351e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions