AcademySoftwareFoundation / AcademySoftwareFoundation/OpenColorIO
Filerules : non-reentry issue in Config::getRuleFromFilepath public function
- Dominant language
- C++
- Stars
- 2.1k
- Forks
- 503
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/AcademySoftwareFoundation/OpenColorIO/blob/05466120f3f9c23b23778f3ccbafc4dde93abe4b/src/OpenColorIO/FileRules.cpp#L638C25-L638C32
Hello,
I've recently migrated my code from the deprecated Config::parseColorSpaceFromString to the recommended Config::getColorSpaceFromFilepath, and encountered a thread-safety issue.
In FileRules::Impl::getRuleFromFilepath(), the method matches() is called in what appears to be a read-only context, implying it should be thread-safe.
However, when a rule is of type FILE_RULE_PARSE_FILEPATH, the matches() method may modify the internal m_colorspace member as a side effect. This introduces shared mutable state, which breaks thread safety when getColorSpaceFromFilepath() is used concurrently on a shared ConstConfigRcPtr.
This behavior leads to data races or inconsistent results in my multi-threaded application.
Contributor guide
Assessment
This issue has not been assessed yet.