mirror of
https://github.com/opencv/opencv.git
synced 2025-06-12 12:22:51 +08:00
Merge pull request #24581 from vrabaud:tsan
Fix race condition in color_lab.cpp initLabTabs(). #24581 There is a race condition between when the static bool is initialized (which is thread safe) and its value check. This PR changes the static bool to a static lambda call to make it thread safe. The static_cast<void> in the end is to prevent unused variables warnings. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work
This commit is contained in:
parent
49463c4420
commit
06f62a3dd1
@ -1223,10 +1223,7 @@ static LABLUVLUT_s16_t initLUTforLABLUVs16(const softfloat & un, const softfloat
|
||||
}
|
||||
|
||||
|
||||
static void initLabTabs()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if(!initialized)
|
||||
static bool createLabTabs()
|
||||
{
|
||||
softfloat f[LAB_CBRT_TAB_SIZE+1], g[GAMMA_TAB_SIZE+1], ig[GAMMA_TAB_SIZE+1];
|
||||
softfloat scale = softfloat::one()/softfloat(LabCbrtTabScale);
|
||||
@ -1333,9 +1330,13 @@ static void initLabTabs()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool initLabTabs()
|
||||
{
|
||||
static bool initialized = createLabTabs();
|
||||
return initialized;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user