refactor: SG-44489: Replace several boost threading usages with std::thread and address sanitizer reported issues - #1313
Open
markreidvfx wants to merge 9 commits into
Conversation
AddressSanitizer identified a new-delete-type-mismatch in threadState. The feature is unused anywhere in the codebase; removing it eliminates the bug and the dead code. Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Starting a thread in the constructor risks accessing members still being initialized. Identified by ThreadSanitizer. Add an explicit start() method called post-construction and remove the unnecessary threadTrampoline wrapper. Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
m_runLock was not being destroyed previously. Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Signed-off-by: Mark Reid <markreid@netflixanimation.com>
Rewrite stl_ext::thread_group to use C++ standard library threading primitives instead of raw pthreads wrappers. - Replace manual pthread_mutex/cond lock/unlock/signal/broadcast helpers with std::mutex, std::condition_variable, and std::lock_guard - Replace the complex worker-wait/signal dispatch model with a std::queue<Job> work queue that workers pull from - Simplify thread_main from a three-phase wait/jump/cleanup cycle to a straightforward dequeue-and-execute loop - Merge dispatch() and maybe_dispatch() into a single internal_dispatch() that pushes to the queue - Simplify destructor: set m_running=false, notify all, join. No more noop dispatch workaround or manual mutex/cond teardown - Replace platform-specific gettimeofday/GetSystemTimeAsFileTime with std::chrono - Remove cancel() (pthread_cancel) which was unsafe - Net reduction of ~600 lines Signed-off-by: Mark Reid <markreid@netflixanimation.com>
markreidvfx
requested review from
bernie-laberge,
cedrik-fuoco-adsk and
eloisebrosseau
as code owners
June 22, 2026 03:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summarize your change.
Replace Boost threading primitives (
boost::mutex,boost::thread_group, raw pthreads) with C++ standard library equivalents (std::mutex,std::thread,std::lock_guard,std::condition_variable). Also fix two issues identified by sanitizers: remove unusedthreadStatecode (AddressSanitizer new-delete-type-mismatch) and defer thread start inTwkMediaLibraryuntil after construction (ThreadSanitizer data race).Describe the reason for the change.
The Boost threading wrappers add unnecessary complexity and dependencies. The
stl_ext::thread_groupimplementation used raw pthreads with manual mutex/cond management and a complex worker dispatch model. Replacing it withstd::thread,std::queue, andstd::condition_variablesimplifies the code significantly (net reduction of ~600 lines) and removes platform-specific timing code. The two bug fixes address real issues found by AddressSanitizer and ThreadSanitizer.Describe what you have tested and on which operating system.
Tested on Rocky Linux 9.
Add a list of changes, and note any that might need special attention during the review.
Thread.h/Thread.cpp: Remove unusedthreadStatecode flagged by AddressSanitizer.Library.h/Library.cpp: Defer thread start until after construction; removethreadTrampolinewrapper.ALSAAudioRenderer.h/.cpp,ALSASafeAudioRenderer.h/.cpp: Replaceboost::mutexwithstd::mutex.ThreadedMovie.h/.cpp: Replaceboost::mutexwithstd::mutexand adoptstd::lock_guard. Fixesm_runLocknot being destroyed previously.MovieFBWriter.cpp: Replaceboost::mutexwithstd::mutex.thread_group.h/thread_group.cpp: Rewrite to usestd::thread,std::queue,std::mutex,std::condition_variable. Remove raw pthreads,cancel(), and platform-specific timing. Net reduction of ~600 lines.main.cppfiles: Remove unusedboost::thread_groupincludes.