Skip to content

Fix crash due to concurrent access in MidiController (Alternative)#14159

Merged
acolombier merged 11 commits intomixxxdj:2.5from
daschuer:gh13940_2
Mar 11, 2025
Merged

Fix crash due to concurrent access in MidiController (Alternative)#14159
acolombier merged 11 commits intomixxxdj:2.5from
daschuer:gh13940_2

Conversation

@daschuer
Copy link
Copy Markdown
Member

@daschuer daschuer commented Jan 10, 2025

This is an alternative to fix #13940

I have now "hopfully" managed to wrap my head around the issue. The issue was that the mapping has been cloned from the GUI thread while the Controller thread has applied JS created mappings. This creates a broken copy of the mapping that crashes Mixxx after it was applied back to the Controller thread.

The solution here keeps now a clean mutable copy of the mapping for the GUI thread. The GUI thread waits until the controller thread has cloned the mapping during "Apply" this way we have sorted out all concurrent access to the mappings.

This PR is unfortunately a big bigger than expected, because some related code and comments have not been maintained over the years and was misleading making the issue hard to understand.

@daschuer
Copy link
Copy Markdown
Member Author

@mxmilkiib Can you check out his?

@daschuer
Copy link
Copy Markdown
Member Author

@mxmilkiib I have added mutex with debug Information.
This will hopefully finally fix the crash. However It needs some polishing.
Please Test and provide the mixxx.log. (or the backtrace if it is still crashing)

@daschuer
Copy link
Copy Markdown
Member Author

@mxmilkiib Does this still crash?

@mxmilkiib
Copy link
Copy Markdown
Contributor

yes

maaaybe this is config file related, removing files manually but Mixxx not forgetting

can't remember the state from before though

@daschuer
Copy link
Copy Markdown
Member Author

Can you please share the mixxx.log of the crash?
A backtrace is also helpful.

@mxmilkiib
Copy link
Copy Markdown
Contributor

ah this is the older issue

I'll see if I can replicate now, not had any recent ones for this issue though, building from this branch that is

@daschuer
Copy link
Copy Markdown
Member Author

Cool, please also share the mixxx.log from a short test run without crash. This will help me polishing.

@mxmilkiib
Copy link
Copy Markdown
Contributor

mxmilkiib commented Jan 30, 2025

https://gist.github.com/mxmilkiib/b223874ec20f85b07840b7e0d2a5ba55

I managed to make it crash, on clicking play though.

DEBUG ASSERT: "it == cbegin() || it == cend() || *it >= position" in function mixxx::Beats::ConstIterator mixxx::Beats::iteratorFrom(mixxx::audio::FramePos) const at ./src/track/beats.cpp:470

Otherwise, no problem experienced (except the waveforms were lo res, idk).

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Feb 7, 2025

The crasher is unrelated and tracked here:
#13262

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Mar 2, 2025

@mxmilkiib Please test if the crasher is fixed now.

@mxmilkiib
Copy link
Copy Markdown
Contributor

I haven't had any further issues so I guess draw a line under it for now.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Mar 3, 2025

Thank you for confirming.
This is ready for review now.

@daschuer daschuer added this to the 2.5.1 milestone Mar 3, 2025
Copy link
Copy Markdown
Member

@acolombier acolombier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code's LGTM, but no Midi mapping to test it with. Looks reasonably safe to merge without it, thanks!

@acolombier acolombier merged commit e932253 into mixxxdj:2.5 Mar 11, 2025
m_pControllerManager.get(),
&ControllerManager::slotApplyMapping);
&ControllerManager::slotApplyMapping,
Qt::BlockingQueuedConnection);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has introduced a deadlock when using with screen controller, which rely on the main thread (GUI) availability (see doc)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

qhash.h:790 ASSERT on multiple MIDI messages in quick succession

3 participants