-
Notifications
You must be signed in to change notification settings - Fork 20
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
panic: runtime error: index out of range [0] with length 0 #28
Comments
Per stack trace, unbound is trying to write an invalid response without the question in it. |
#25 Seems related |
It's the same mode of failure. Probably best to figure out why that happens in the first place in if len(res.AnswerPacket.Question) == 0 {
res.AnswerPacket.Question = r.Question
} Although it would be a safer hack to SERVFAIL when if err != nil || len(res.AnswerPacket.Question) == 0 {
return dns.RcodeServerFailure, err
} |
Will you make a PR? I'm not good with golang. |
do you have a test case? I think I can paper over it in miekg/unbound, but not sure if that is the best approach |
A papered over solution probably better to live here in the plugin - e.g. to return SERVFAIL if the AnswerPacket is missing a Question. |
proper fix upstream with miekg/unbound#18. Thanks miekg! |
Can the fix be applied in this repo since the upstream fix has stalled before being merged? It has been over a year, so I assume it won't be. |
I think my issue might be related to this one since I'm getting same error message "[ERROR] Recovered from panic in server: "dns://:53" runtime error: index out of range [0] with length 0" with unbound plugin when I try to resolve IBM Cloud Kafka broker instance - broker-5-48d5s71514qnmqz3.kafka.svc11.us-south.eventstreams.cloud.ibm.com. Seems like it might be related to trying to resolve long sub-domains, but again not sure. When I was testing this 9/10 times it throws error message above and only once time it resolves and returns CNAME. |
I echo the need for miekg/unbound#18 to be patched in this repo since upstream has stalled on merging in the fix. For others that are looking for a quick not ideal workaround you can manually patch the three line change with the following: Grab the patch from the PR: curl -sL -o pr18.patch https://patch-diff.githubusercontent.com/raw/miekg/unbound/pull/18.patch If you are using a container to build a custom CoreDNS binary with this plugin you can apply it with the following: RUN go mod download
COPY plugin.cfg $GOPATH/src/github.com/coredns/coredns
RUN make gen
COPY pr18.patch /root/go/pkg/mod/github.com/miekg/unbound\@v0.0.0-20210309082708-dbeefb4cdb29
WORKDIR /root/go/pkg/mod/github.com/miekg/unbound\@v0.0.0-20210309082708-dbeefb4cdb29
RUN patch -p1 < pr18.patch
WORKDIR $GOPATH/src/github.com/coredns/coredns I have tested this with the latest CoreDNS 1.11.3 pre-release and it works as expected: $ podman exec coredns drill A 2.0.0.127.zen.spamhaus.org
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 51610
;; flags: qr rd ra ; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; 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.4
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
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
;; Query time: 392 msec
;; SERVER: 127.0.0.1
;; WHEN: Mon Jun 10 18:09:10 2024
;; MSG SIZE rcvd: 170 |
I clicked a button |
@miekg you are the best! Thanks dude! |
What happened:
Facing panic: runtime error: index out of range [0] with length 0
What you expected to happen:
No runtime panic.
How to reproduce it (as minimally and precisely as possible):
Do not know - happens periodically.
Anything else we need to know?:
Dockerfile:
Environment:
cat /etc/os-release
):docker version:
The text was updated successfully, but these errors were encountered: