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::registerreturns astd::io::Result::Err, ifisahc::agent::selector::is_bad_socket_errorreturnsfalse.isahc::agent::AgentContext::pollthen calls thestd::io::Result::unwrapmethod on theErrvariant. This causes a panic and that in turn causes a segmentation fault. I think there two bigger issues here:isahc::agent::AgentContext::pollshould 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
pollinguses. I do not know what it means forpoller.addand/orpoller.modifyto return astd::io::Result::Errvariant whosestd::io::Error::kindmethod returns astd::io::ErrorKind::PermissionDeniedvariant. But the panic and the subsequent segmentation fault are prevented, ifis_bad_socket_errorreturnstruein that case.Possible ramifications of returning
trueonstd::io::ErrorKind::PermissionDeniedare unknown to me. What ifpoller.addorpoller.modifyconstantly returnPermissionDenieddue to insufficient user privileges? Is it possible for that to cause an infinite loop of trying to callpoller.addorpoller.modifyand them returingPermissionDeniedover and over again?The
segfaultintegration test and the associatedrun-segfault-integration-test-repeatedly.shscript, 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.