-
Notifications
You must be signed in to change notification settings - Fork 154
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
Modify toSpanData
to happen inside attributesLock
to prevent data races
#632
Modify toSpanData
to happen inside attributesLock
to prevent data races
#632
Conversation
Sorry I just realized that it must be locked also with the other lock (the event one) as also events could be modified in while calling it ( this pattern is also used in the stop method) |
You're right! that lock also wraps properties that are going to be used by the |
Seems like adding the |
Yes, if all the calls being made by the method are covered then it is not needed. It was my fault asking you to add it, I should have checked first, sorry. |
No problem! did the rollback! Hope next run works fine |
It worked with last changes so I merged. Thanks a lot. |
Overview
This PR addresses a potential data race issue when
toSpanData()
is called concurrently with modifications toattributes
by wrapping both operations within the same lock.Explanation
When somebody needs to call
toSpanData
during the lifetime of aSpan
, thetoSpanData()
method accessesattributes
andtotalAttributeCount
while another thread may be modifying them (each time anattribute
is added/removedtotalAttributeCount
is also modified), leading to potential crashes or memory corruption.Fixes #630