Skip to content

Panic error when resolving 2.0.0.127.zen.spamhaus.org. #29

Open
@webaddicto

Description

@webaddicto

What happened:

When I try to resolve "2.0.0.127.zen.spamhaus.org." with dig:

dig a 2.0.0.127.zen.spamhaus.org.

I see CoreDNS outputs this:

[ERROR] Recovered from panic in server: "dns://:53" runtime error: index out of range [0] with length 0

So I added "debug" plugin and here is the result:

panic: runtime error: index out of range [0] with length 0
goroutine 88 [running]:
github.com/coredns/coredns/plugin/cache.key({0xc0003743c0, 0x707b8f}, 0x4aa8c5, 0x0)
        /root/coredns2/coredns/plugin/cache/cache.go:80 +0x85
github.com/coredns/coredns/plugin/cache.(*ResponseWriter).WriteMsg(0xc0000e4840, 0xc0006158c0)
        /root/coredns2/coredns/plugin/cache/cache.go:151 +0xd9
github.com/coredns/unbound.(*Unbound).ServeDNS(0xc000100410, {0x22c7598, 0xc000661290}, {0x22f96a8, 0xc0000e4840}, 0xc0006157a0)
        /root/go/pkg/mod/github.com/coredns/[email protected]/unbound.go:140 +0x538
github.com/coredns/coredns/plugin.NextOrFailure({0x1ec14d6, 0xc00006e800}, {0x22aa560, 0xc000100410}, {0x22c7598, 0xc000661290}, {0x22f96a8, 0xc0000e4840}, 0x1e57660)
        /root/coredns2/coredns/plugin/plugin.go:80 +0x264
github.com/coredns/coredns/plugin/cache.(*Cache).doRefresh(0xc00020bb80, {0x22c7598, 0xc000661290}, {0xc0006157a0, {0x22f9910, 0xc000383240}, {0x0, 0x0}, 0x1000, 0x0, ...}, ...)
        /root/coredns2/coredns/plugin/cache/handler.go:77 +0xd9
github.com/coredns/coredns/plugin/cache.(*Cache).ServeDNS(0xc00020bb80, {0x22c7598, 0xc000661290}, {0x22f9910, 0xc000383240}, 0x0)
        /root/coredns2/coredns/plugin/cache/handler.go:43 +0x94e
github.com/coredns/coredns/plugin.NextOrFailure({0x1ebff91, 0x1}, {0x22a9e80, 0xc00020bb80}, {0x22c7598, 0xc000661290}, {0x22f9910, 0xc000383240}, 0x1c9eca0)
        /root/coredns2/coredns/plugin/plugin.go:80 +0x264
github.com/coredns/coredns/plugin/log.Logger.ServeDNS({{0x22a9e80, 0xc00020bb80}, {0xc00047e510, 0x1, 0x1}, {}}, {0x22c7598, 0xc000661290}, {0x22f9a18, 0xc000120b10}, ...)
        /root/coredns2/coredns/plugin/log/log.go:36 +0x346
github.com/coredns/coredns/core/dnsserver.(*Server).ServeDNS(0xc00036e4e0, {0x22c7598, 0xc000661290}, {0x22f9a18, 0xc000120b10}, 0xc000615710)
        /root/coredns2/coredns/core/dnsserver/server.go:280 +0x64d
github.com/coredns/coredns/core/dnsserver.(*Server).ServePacket.func1({0x22fb4e8, 0xc0001fcc00}, 0xc000615701)
        /root/coredns2/coredns/core/dnsserver/server.go:128 +0x9b
github.com/miekg/dns.HandlerFunc.ServeDNS(0xc0000e7000, {0x22fb4e8, 0xc0001fcc00}, 0xc000615710)
        /root/go/pkg/mod/github.com/miekg/[email protected]/server.go:37 +0x2f
github.com/miekg/dns.(*Server).serveDNS(0xc000618900, {0xc0000e7000, 0x43, 0x0}, 0xc0001fcc00)
        /root/go/pkg/mod/github.com/miekg/[email protected]/server.go:659 +0x43e
github.com/miekg/dns.(*Server).serveUDPPacket(0xc000618900, 0x0, {0xc0000e7000, 0x43, 0x200}, {0x22ecad0, 0xc0003520f0}, 0xc0005cb160, {0x0, 0x0})
        /root/go/pkg/mod/github.com/miekg/[email protected]/server.go:603 +0x1dc
created by github.com/miekg/dns.(*Server).serveUDP
        /root/go/pkg/mod/github.com/miekg/[email protected]/server.go:533 +0x485

This is the Corefile I am using:

.:53 {
    unbound
    cache    
    log
}

What you expected to happen:

It should not show the panic error.

But additionally, it should show an answer same as by using 1.1.1.1:

; <<>> DiG 9.16.22-Debian <<>> A 2.0.0.127.zen.spamhaus.org.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53566
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;2.0.0.127.zen.spamhaus.org.    IN      A

;; ANSWER SECTION:
2.0.0.127.zen.spamhaus.org. 60  IN      A       127.0.0.2
2.0.0.127.zen.spamhaus.org. 60  IN      A       127.0.0.10
2.0.0.127.zen.spamhaus.org. 60  IN      A       127.0.0.4

;; Query time: 39 msec
;; SERVER: 1.1.1.1#53(1.1.1.1)
;; WHEN: Wed Feb 23 00:47:17 UTC 2022
;; MSG SIZE  rcvd: 103

Instead it shows nothing (probably due to the crash), and sometimes I see this in the log:

[INFO] XXXXXXX:51176 - 61915 "A IN 2.0.0.127.zen.spamhaus.org. udp 67 false 4096" NXDOMAIN qr,rd,ra 136 0.755868575s

It is not able to resolve the DNSBL address?

How to reproduce it (as minimally and precisely as possible):

Use same Corefile as shown above and then use dig like this:

dig a 2.0.0.127.zen.spamhaus.org.

It should show the panic error, sometimes it shows the NXDOMAIN so just retry a few times.

Anything else we need to know?:

Environment:

Debian GNU/Linux 11 (bullseye)
CoreDNS-1.9.0
linux/amd64, go1.17.7

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions