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

DNSClient possibly not thread safe #19

Closed
adam-fowler opened this issue Jul 11, 2022 · 6 comments
Closed

DNSClient possibly not thread safe #19

adam-fowler opened this issue Jul 11, 2022 · 6 comments

Comments

@adam-fowler
Copy link

It crashes in DNSClient.send. It looks like multiple threads can access dnsDecoder.messageCache at the same time. I got this crash with the following code

let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let client = try await DNSClient.connectTCP(
                    on: eventLoopGroup.next(),
                    host: "1.1.1.1"
                ).get()
async let result = client.initiateAAAAQuery(host: hostname, port: 0).get()
async let result2 = client.initiateAAAAQuery(host: hostname, port: 0).get()
async let result3 = client.initiateAAAAQuery(host: hostname, port: 0).get()
@JaapWijnen
Copy link
Contributor

Thanks for the code example! I'll take a look

@JaapWijnen
Copy link
Contributor

@adam-fowler I made sure the message cache is only accessed from the event loop in #20 . Could you check if this works as expected for your dns setup?

@adam-fowler
Copy link
Author

That seems to have fixed the crash

@JaapWijnen
Copy link
Contributor

Awesome, I had some trouble testing myself because the requests after my first were timing out. What did you use to test?

@adam-fowler
Copy link
Author

@JaapWijnen There might be a problem. It seems to stall sometimes now

@Joannis
Copy link
Member

Joannis commented Dec 10, 2022

Closing this, as the issue was elsewhere for that project.

@Joannis Joannis closed this as completed Dec 10, 2022
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

3 participants