Skip to content

bugfix(audio): Prevent race condition when accessing deleted drawables from audio thread#461

Open
seer-by-sentry[bot] wants to merge 1 commit intomainfrom
seer/bugfix/audio-thread-safety
Open

bugfix(audio): Prevent race condition when accessing deleted drawables from audio thread#461
seer-by-sentry[bot] wants to merge 1 commit intomainfrom
seer/bugfix/audio-thread-safety

Conversation

@seer-by-sentry
Copy link
Copy Markdown

Fixes CLIENT-4BM. The issue was that: Audio thread accesses freed Drawable memory via findDrawableByID due to a race condition with main thread's object destruction.

  • Introduced a new mutex, m_drawableLookupMutex, in GameClient to guard drawable lookup access and drawable lifetime.
  • Initialized the mutex in the GameClient constructor and closed it in the destructor.
  • Modified GameClient::removeDrawable to acquire the m_drawableLookupMutex before removing a drawable from the lookup table and freeing its memory, preventing concurrent access by other threads.
  • Modified AudioEventRTS::getPosition to acquire the m_drawableLookupMutex when looking up a drawable by ID and retrieving its position, ensuring the drawable is not deleted mid-operation by the main thread.
  • Included Common/ScopedMutex.h in relevant files to facilitate mutex usage.

This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 13189844

Not quite right? Click here to continue debugging with Seer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants