mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 13:13:26 +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,11 +1223,8 @@ static LABLUVLUT_s16_t initLUTforLABLUVs16(const softfloat & un, const softfloat
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void initLabTabs()
|
static bool createLabTabs()
|
||||||
{
|
{
|
||||||
static bool initialized = false;
|
|
||||||
if(!initialized)
|
|
||||||
{
|
|
||||||
softfloat f[LAB_CBRT_TAB_SIZE+1], g[GAMMA_TAB_SIZE+1], ig[GAMMA_TAB_SIZE+1];
|
softfloat f[LAB_CBRT_TAB_SIZE+1], g[GAMMA_TAB_SIZE+1], ig[GAMMA_TAB_SIZE+1];
|
||||||
softfloat scale = softfloat::one()/softfloat(LabCbrtTabScale);
|
softfloat scale = softfloat::one()/softfloat(LabCbrtTabScale);
|
||||||
int i;
|
int i;
|
||||||
@ -1333,9 +1330,13 @@ static void initLabTabs()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
initialized = true;
|
static bool initLabTabs()
|
||||||
}
|
{
|
||||||
|
static bool initialized = createLabTabs();
|
||||||
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user