Skip to content

Curl_resolver_init is not thread-safe #13065

Description

@nickitat

I did this

Hi!

We start getting sanitiser reports like this in our CI.

I assume that this code is supposed to be thread-safe, please correct me if I'm wrong.

If so, seems like the problematic code was introduced recently here:

4224d6e

so static variable ares_ver could be simultaneously read and modified by two threads.
it seems enough to replace l. 176 with

static int ares_ver = get_ares_version();

get_ares_version() will do the same call, but now compiler will guarantee single initialisation (btw, I'm not a C expert, do we have this guarantee in C?).

I expected the following

no sanitiser complains

curl/libcurl version

curl 8.6.0+

operating system

linux

Activity

  1. jay commented on Mar 6, 2024

    @jay
    Member

    I don't see get_ares_version in our source or the c-ares api. See #13066 for proposed fix

  2. added a commit that references this issue on Mar 6, 2024
  3. bagder commented on Mar 7, 2024

    @bagder
    Member

    I'm pretty sure this is still thread safe, even if we should make it done nicer.

  4. nickitat commented on Mar 7, 2024

    @nickitat
    Author

    thank you, guys
    when could we expect the next release?

  5. bagder commented on Mar 7, 2024

    @bagder
    Member

    The next release ships on March 27, 2024 and will become version 8.7.0. The pending release notes for the coming release are always available on this URL: https://curl.se/dev/release-notes.html

  6. nickitat commented on Mar 7, 2024

    @nickitat
    Author

    I'd also love to get your advice on how we should proceed on our end. is it safe to use master version instead of the last release? to get the fix earlier. or maybe we could back-port the fix to the last release branch?

  7. jay commented on Mar 7, 2024

    @jay
    Member

    is it safe to use master version instead of the last release? to get the fix earlier. or maybe we could back-port the fix to the last release branch?

    Do not use master in production. master is our development branch. I suggest use git to cherry pick the fixes you need.

  8. bagder commented on Mar 7, 2024

    @bagder
    Member

    is it safe to use master version instead of the last release?

    I believe sticking to the previous version is fine until the next release ships. I think this not thread-safe warning was a warning and it should be and was fixed, but the effects of the problem are totally harmless.

  9. added 2 commits that reference this issue on Mar 12, 2024
    44f011d
    1a05e83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions