Repository navigation
fix(errkit): return ErrKindUnknown from Kind without storing it - #828
Open
dwisiswant0 wants to merge 1 commit into
Open
dwisiswant0 wants to merge 1 commit into
dwisiswant0 wants to merge 1 commit into
Conversation
When an error had no kind, Kind() assigned ErrKindUnknown to e.kind before returning it, so the getter wrote to its receiver. An *ErrorX is often a package-level sentinel read from many goroutines, and concurrent Kind() calls on one raced on that interface field. The write also changed the error: parseError copies the kind into every error that wraps the sentinel, so after one Kind() call those errors reported unknown-error instead of no kind. Errors given a kind with SetKind never reached the assignment, which is why they did not race. Return the fallback without storing it, as Kind() did before bb8871e, and document on ErrorX that only its setters modify it, so the other methods stay safe to call on a shared error. fastdialer calls Kind() on every dial error it returns, so the dial errors it leaves unclassified used to carry ErrKindUnknown and now carry no kind, which GetErrorKind reports as an empty kind (#827). For those errors, GetErrorKind and the kind field in nuclei's error log change from "unknown-error" to "", IsKind(err, ErrKindUnknown) returns false, and GetAllErrorKinds stops listing ErrKindUnknown next to a kind it detects. IsKind against any other kind returns what it did before. Fixes: #826 Refs: #827 Signed-off-by: Dwi Siswanto <git@dw1.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When an error had no kind, Kind() assigned ErrKindUnknown to e.kind
before returning it, so the getter wrote to its receiver. An *ErrorX
is often a package-level sentinel read from many goroutines, and
concurrent Kind() calls on one raced on that interface field. The
write also changed the error: parseError copies the kind into every
error that wraps the sentinel, so after one Kind() call those errors
reported unknown-error instead of no kind. Errors given a kind with
SetKind never reached the assignment, which is why they did not race.
Return the fallback without storing it, as Kind() did before bb8871e,
and document on ErrorX that only its setters modify it, so the other
methods stay safe to call on a shared error.
fastdialer calls Kind() on every dial error it returns, so the dial
errors it leaves unclassified used to carry ErrKindUnknown and now
carry no kind, which GetErrorKind reports as an empty kind (#827).
For those errors, GetErrorKind and the kind field in nuclei's error
log change from "unknown-error" to "", IsKind(err, ErrKindUnknown)
returns false, and GetAllErrorKinds stops listing ErrKindUnknown
next to a kind it detects. IsKind against any other kind returns
what it did before.
Fixes: #826
Refs: #827