Skip to content
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 SpectralCoordinate's toWorld/toPixel #1235

Merged
merged 1 commit into from Dec 21, 2022

Conversation

rtobar
Copy link
Contributor

@rtobar rtobar commented Nov 1, 2022

These two functions use a static 1-element Vector to avoid allocations on each invocation; however these static vectors are shared across multiple threads, leading to race conditions on unlocked data access and therefore unexpected results.

This commit adds the thread_local specifier on these static variables such that in multi-threaded scenarios each thread ends up with its own static copy of the variable, thus avoiding unlocked data shared across threads.

This issue was originally reported in #1200, and then more specifically in #1217.

Signed-off-by: Rodrigo Tobar rtobar@icrar.org

These two functions use a static 1-element Vector to avoid allocations
on each invocation; however these static vectors are shared across
multiple threads, leading to race conditions on unlocked data access and
therefore unexpected results.

This commit adds the thread_local specifier on these static variables
such that in multi-threaded scenarios each thread ends up with its own
static copy of the variable, thus avoiding unlocked data shared across
threads.

This issue was originally reported in casacore#1200, and then more specifically
in casacore#1217.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
@tammojan tammojan merged commit 348cfb7 into casacore:master Dec 21, 2022
@rtobar rtobar deleted the spectral-coordinate-mt-fix branch December 21, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants