-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 condition, concurrent writes to the err variable, causes Undefined Behavior #11349
Fix data race condition, concurrent writes to the err variable, causes Undefined Behavior #11349
Conversation
…s UB Signed-off-by: Bogdan Drutu <[email protected]>
4b2d190
to
b591926
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11349 +/- ##
=======================================
Coverage 91.54% 91.54%
=======================================
Files 428 428
Lines 20230 20233 +3
=======================================
+ Hits 18519 18522 +3
Misses 1337 1337
Partials 374 374 ☔ View full report in Codecov by Sentry. |
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.
I am honestly surprised that the golangci-lint or the race detector didn't catch this.
The other way you could resolve this is by having a named returned value for the lambda being created so that would shadow the error previously defined. However, this would be flagged by the shadow linter.
Alternatively, discourage anonymous functions being declared within methods could also be another way to stop this from occurring again in the project?
…s Undefined Behavior (open-telemetry#11349) The main issue is that after open-telemetry#10910 the err variable is shared between requests because it uses the same address as the err defined outside the func. This is an UB because we are overwriting memory and will cause crashes like open-telemetry#11335, where the check for not nil happens then gets overwrite with nil and crashes. Fixes open-telemetry#11350 --------- Signed-off-by: Bogdan Drutu <[email protected]>
…s Undefined Behavior (open-telemetry#11349) The main issue is that after open-telemetry#10910 the err variable is shared between requests because it uses the same address as the err defined outside the func. This is an UB because we are overwriting memory and will cause crashes like open-telemetry#11335, where the check for not nil happens then gets overwrite with nil and crashes. Fixes open-telemetry#11350 --------- Signed-off-by: Bogdan Drutu <[email protected]>
The main issue is that after #10910 the err variable is shared between requests because it uses the same address as the err defined outside the func.
This is an UB because we are overwriting memory and will cause crashes like #11335, where the check for not nil happens then gets overwrite with nil and crashes.
Fixes #11350