-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix data race in error path #4
Conversation
Fixes a data race in ToMiddleware() by creating a new instance of the err variable in the returned function.
@larsve could you provide testcase showing this race. I struggling to understand how this can be racy. Is it because that error instance is created at |
Yes, I hit that issue when GO's race detector broke my integration test, complaining about:
And se far as I could see, it complained because the returned function is reusing the err instance that is created in the ToMiddleware() func. With this fix, the race detector isn't triggered anymore. |
As I understand the issue, it's when there are concurrent calls to the returned function, since every call to the returned function is reusing the same err variable. |
Added a small testcase now, if I revert my fix, I get this when running
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'll release patch release asap |
Fixes a data race in ToMiddleware() by creating a new instance of the err variable in the returned function.