Reported in IRC: it could conceivably be from dns_found_answer() or connection_exit_connect.
If so (or even if not), I suggest two fixes and a workaround:
Every place that calls connection_free except for connection_unlink(), we need to audit to make it's not reachable on on an already-marked-for-close connection.
We should start with the two places above.
We should change the behavior of connection_free() for a connection on the closeable list to log a bug and return, rather than freeing the connection. Since it's on the closeable list, it should get freed soon anyway.)
The reporter suggests that we should call connection_dns_remove earlier (perhaps when we mark connections?), and that it should work differently. more info to follow
Yes, you no need any action if got answer for already closed connection. You can't to send any answer back. You can't establish requested connection. Connection was marked for close. The End.
You can reformat patch, it duplicates lines with removing action:
During package installation of gdb I noticed that my local dns resolver unbound did not work. Had to restart the daemon. I am wondering if this has something to do with this error?
This can happen in practice when dns_resolve_impl() gets a request for something that was already answered and cached, then the new request is cancelled (by an end cell), and the cached version expires while the request is pending. Then purge_expired_resolves() finds something on resolve->pending_connections and proceeds to free it, but it's on the closeable_list too.
Diagnosed by our irc person. We agree that this race condition seems hard to intentionally exploit in practice.
This can happen in practice when dns_resolve_impl() gets a request for something that was already answered and cached
Not already answered and cached. It has to sit in the pending queue for the 300 seconds, and then have another request appear during that 300 seconds, and have that other request get ended at just the right time.
So it sounds like Torland's "my unbound was broken at the time" hint is relevant.
Diagnosed by our irc person. We agree that this race condition seems hard to intentionally exploit in practice.