AcademySoftwareFoundation / AcademySoftwareFoundation/OpenImageIO
[BUG] OpenImageIO's default thread pool initialization has a data race.
- Dominant language
- C++
- Stars
- 2.4k
- Forks
- 698
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 46
Description
**Describe the bug**
A clear and concise description of what the bug is. What happened, and
what did you expect to happen instead.
OpenImageIO's default thread pool initialization seems to have a data race.
In OpenImageIO 2.4.8 (and it seems to still be the same in upstream main)
```
thread_pool::thread_pool
-> thread_pool::Impl::Impl
-> thread_pool::Impl::resize
-> thread_pool::Impl::set_thread
-> starts a new thread using the lambda f
-> that lambda references thread_pool::Impl::q before thread_pool::Impl's constructor has finished on the main thread
```
Full TSAN error with proprietary parts of the stack removed beloe
**OpenImageIO version and dependencies**
2.4.8
**Evidence**
- Error messages (paste them here exactly)
- Screenshots (if helpful)
- Example input: If the problem only happens with certain image files, please
attach the smallest image you can make that reproduces the problem.
**IF YOU ALREADY HAVE A CODE FIX:** There is no need to file a separate issue,
please just go straight to making a [pull request](https://github.com/AcademySoftwareFoundation/OpenImageIO/pulls).
Contributor guide
Research direction
Start with the thread_pool::thread_pool → thread_pool::Impl::Impl → resize → set_thread call chain described in the issue. Reproduce the initialization under ThreadSanitizer and inspect when the worker lambda accesses Impl::q relative to construction. Done means the reported data race is eliminated and the ThreadSanitizer failure no longer occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100