Skip to content

Fix use-after-free race condition in visualizer#130

Merged
nyanpasu64 merged 1 commit intoDn-Programming-Core-Management:masterfrom
nyanpasu64:fix-visualizer-lock
Apr 22, 2022
Merged

Fix use-after-free race condition in visualizer#130
nyanpasu64 merged 1 commit intoDn-Programming-Core-Management:masterfrom
nyanpasu64:fix-visualizer-lock

Conversation

@nyanpasu64
Copy link
Copy Markdown
Collaborator

Fixes a race condition causing the visualizer thread's CVisualizerWnd::ThreadProc() to pass freed memory (pDrawBuffer) to CVisualizerBase::SetSampleData(). This could occur randomly upon changing buffer size on DirectSound, or randomly on WASAPI. When it happens, the visualizer can display corrupted contents or even segfault.

To reproduce the bug easily, checkout master without this branch's changes, then edit CVisualizerWnd::ThreadProc() and add Sleep(50); after m_csBufferSelect.Unlock(); before m_csBuffer.Lock();.

This does not rewrite the entire visualizer system unlike #127. This is good since master (and this branch)'s oscilloscope visualizer is less choppy on DirectSound than #127, and WASAPI (which replaces DirectSound) isn't merged yet.

@nyanpasu64 nyanpasu64 force-pushed the fix-visualizer-lock branch from efd641a to a6577b1 Compare April 22, 2022 02:10
@nyanpasu64 nyanpasu64 merged commit 0f6b568 into Dn-Programming-Core-Management:master Apr 22, 2022
@nyanpasu64 nyanpasu64 deleted the fix-visualizer-lock branch April 22, 2022 02:50
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.

1 participant