Skip to content

Individual wireLookupUDP not obeying the lookupCtx timeout #565

@phillip-stephens

Description

@phillip-stephens

Received an email from a user. I'll edit this issue with more concise bug description and reproducibility info as I triage.

Dear Mr. Phillip,
I hope this email finds you well. I am writing to report an issue I've encountered while using zdns v2.0.4 in a production environment.
Problem Description:
I've observed that DNS queries are hanging for extended periods (over 2 minutes) despite having configured shorter timeout values. Through pprof analysis, I can see multiple goroutines stuck in IO wait state during DNS read operations.
Technical Details:
zdns version: v2.0.4
The goroutines are blocked at github.com/zmap/dns.(*Conn).ReadMsg()
Stack trace shows the execution path: wireLookupUDP → ExchangeWithConnContext → ReadMsg
Expected behavior: Queries should timeout after 2 seconds (the default lookupCtx timeout)
Actual behavior: Queries hang for 2+ minutes before timing out
Code Analysis:
I've reviewed the source code and noticed that wireLookupUDP creates a new lookupCtx with a 2-second timeout for each call. However, the timeout doesn't seem to be properly propagated to the underlying network read operations, particularly at the net.(*conn).Read level.

// write with the appropriate write timeout
t := time.Now()
writeDeadline := t.Add(c.getTimeoutForRequest(c.writeTimeout()))
readDeadline := t.Add(c.getTimeoutForRequest(c.readTimeout()))
if deadline, ok := ctx.Deadline(); ok {
    if deadline.Before(writeDeadline) {
        writeDeadline = deadline
    }
    if deadline.Before(readDeadline) {
        readDeadline = deadline
    }
}
co.SetWriteDeadline(writeDeadline)
co.SetReadDeadline(readDeadline)

Could this issue be caused by SetReadDeadline failing silently?

To Reproduce

  • v2.0.4 ZDNS

Metadata

Metadata

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions