-
-
Notifications
You must be signed in to change notification settings - Fork 54
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: "attempt to calculate the remainder with a divisor of zero" #161
Comments
It seems you are iterating over an empty server list. Did you perchance forget to call |
I did! Well, I used Perhaps it would be better to use a "builder" pattern since finalization is required? What's odd is I explicitly put servers in there. Could this condition happen under different circumstances? let mut conf = ResolvConf::default();
conf.servers = vec![ServerConf::new(config.fwd_addr, TransportKind::Tcp)];
conf.options.timeout = Duration::from_secs(5);
StubResolver::from_conf(conf) Edit: I now see the docs says this is like a builder pattern. I think it's less error-prone to make a |
I agree this should be changed into having a separate builder type. But in any case, looking at the code properly now, it should be able to deal with empty server lists. Could you perchance get a stack trace to see what it’s been doing before it crashed? (Just the domain-related parts of the stack trace are enough.) |
Yes. Initially I thought I wasn't running with the proper
|
This appears to happen repeatedly during the same execution. I'm assuming it can get in a bad state and stay that way. |
Using a stub resolver in the way you build it above works fine here – indeed in this case you don’t need to explicitly finalize t. It also looks in the code like it should handle an empty UDP list correctly by using the TCP list. Can you try and create a minimalist breaking example from your code? I don’t think I’ll get anywhere from just staring at the code longer ;) |
Ah! Maybe this is related them: I have 2 stub resolvers, one for UDP and one for TCP. I'm forwarding queries and I want to keep the same protocol as the original query. let tcp_recursor = {
let mut conf = ResolvConf::default();
conf.servers = vec![ServerConf::new(config.fwd_addr, TransportKind::Tcp)];
conf.options.timeout = Duration::from_secs(5);
StubResolver::from_conf(conf)
};
let udp_recursor = {
let mut conf = ResolvConf::default();
conf.servers = vec![ServerConf::new(config.fwd_addr, TransportKind::Udp)];
conf.options.timeout = Duration::from_secs(5);
StubResolver::from_conf(conf)
}; Later on, I use them like so: let res = match w.kind() {
TransportKind::Udp => self.udp_recursor.query(q).await,
TransportKind::Tcp => self.tcp_recursor.query(q).await,
}; (where Maybe there's a better way to achieve this? My current reasoning is: if the query is UDP, then that's all I can respond with. Often that'll end up being a truncate response and the client will make a second query over TCP, in which case I'll use the TCP resolver.
I don't quite know how this happens :( The server we forward to is a local |
We have a plan to factor our the actual networking from the stub resolver to make it easier to build proxies and such. For the time being, you approach looks good and should work. I guess I’ll stare a bit more at the code to try and figure out why it tries using the empty list. |
Thank you! Anything I can do in the meantime? I deployed our server to more hosts and this seems to happen quite a bit. Restarting the server seems to be the only fix. I do not mind refactoring our own code to circumvent this issue. I could manually reproduce what the stub resolver does without the server logic. We have a single server, so we don't need that whole thing. |
The actual querying code is rather simple. All of it is in The question is turned into a query in |
Thanks! For now I've forked this repo and make |
Cheeky ;) For what it’s worth: Factoring out the transports and making them available directly is probably the next thing we are going to do once I have finished #160. |
I got the following panic:
Looks like this line is problematic:
domain/src/resolv/stub/mod.rs
Lines 708 to 710 in 4fb8fb0
I haven't had time to dig into it, but I can take a look next week.
The text was updated successfully, but these errors were encountered: