Prevent a segmentation fault by making is_bad_socket_error
return true
on std::io::ErrorKind::PermissionDenied
#462
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As described in the issue #460,
isahc::agent::AgentContext::register
returns astd::io::Result::Err
, ifisahc::agent::selector::is_bad_socket_error
returnsfalse
.isahc::agent::AgentContext::poll
then calls thestd::io::Result::unwrap
method on theErr
variant. This causes a panic and that in turn causes a segmentation fault. I think there two bigger issues here:isahc::agent::AgentContext::poll
should not callunwrap
.This pull request is not a fix for either of those issues. Instead, it is a proposal for a minimal change that fixes one case where issues 1 and 2 manifest.
I am unsure, if this is a good fix. I am not familiar with the polling backends that
polling
uses. I do not know what it means forpoller.add
and/orpoller.modify
to return astd::io::Result::Err
variant whosestd::io::Error::kind
method returns astd::io::ErrorKind::PermissionDenied
variant. But the panic and the subsequent segmentation fault are prevented, ifis_bad_socket_error
returnstrue
in that case.Possible ramifications of returning
true
onstd::io::ErrorKind::PermissionDenied
are unknown to me. What ifpoller.add
orpoller.modify
constantly returnPermissionDenied
due to insufficient user privileges? Is it possible for that to cause an infinite loop of trying to callpoller.add
orpoller.modify
and them returingPermissionDenied
over and over again?The
segfault
integration test and the associatedrun-segfault-integration-test-repeatedly.sh
script, available in the pull request #461, can be used to test that the fix introduced in this pull request prevents a panic and the subsequent segmentation fault.