Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't try and set bpm on invalid m_pBeats pointers #1893

Merged
merged 1 commit into from
Nov 6, 2018

Conversation

iamcodemaker
Copy link
Contributor

If no track is loaded and the user presses the bpm_tap button, mixxx will crash. I didn't test this, or write a unit test for it. Scons has suddenly started complaining my compiler does not support c++11, but it looks like this is the cause of the crash.

https://bugs.launchpad.net/mixxx/+bug/1801844

@@ -219,6 +219,9 @@ void BpmControl::slotTapFilter(double averageLength, int numSamples) {
if (numSamples < 4)
return;

if (!m_pBeats)
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch! Could you grab a reference to the shared pointer first so that it can't be deleted between this line and the setBpm call below?

auto pBeats = m_pBeats;
if (!pBeats) {
  return;
}
...
pBeats->setBpm(averageBpm);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do that. Other usages in this file don't do that though. If that's necessary, there might be some race conditions.

@rryan
Copy link
Member

rryan commented Nov 6, 2018

This is a pretty serious bug! Thanks for sending a fix. Could you rebase this onto the 2.1 branch? I'd like to include it in our next stable release (2.1.6).

If no track is loaded and the user presses the bpm_tap button, mixxx
will crash.

https://bugs.launchpad.net/mixxx/+bug/1801844
@iamcodemaker
Copy link
Contributor Author

Rebased, I also updated the merge target to branch 2.1, not sure if that's necessary or not.

@daschuer
Copy link
Member

daschuer commented Nov 6, 2018

The race condition between checking for Null and using the pointer seems to be really an issue. It effects m_pBPM and m_pTrack as well.

We need to check from which thread both is set and then fix at least functins called from other threads. I am afraid other engine controls suffer the same issue.

This may explain the crash recently reported in the forums wen ejecting a track.

@daschuer
Copy link
Member

daschuer commented Nov 6, 2018

I have reported a follow-up bug https://bugs.launchpad.net/bugs/1801874

@daschuer
Copy link
Member

daschuer commented Nov 6, 2018

LGTM

@rryan
Copy link
Member

rryan commented Nov 6, 2018

LGTM as well. Could you please sign the Mixxx contributor agreement? This gives us permission to distribute your change with Mixxx.

@iamcodemaker
Copy link
Contributor Author

AFAIK I have already signed it.

@rryan
Copy link
Member

rryan commented Nov 6, 2018

AFAIK I have already signed it.

Thanks

@rryan rryan merged commit db55f94 into mixxxdj:2.1 Nov 6, 2018
@rryan
Copy link
Member

rryan commented Nov 6, 2018

We need to check from which thread both is set and then fix at least functins called from other threads. I am afraid other engine controls suffer the same issue.

I think it might be worth renaming methods based on their execution context to be easier to read.

Or just deleting the engine and starting over with a design that doesn't have multiple threads touching shared state ;).

@Be-ing
Copy link
Contributor

Be-ing commented Nov 6, 2018

Or just deleting the engine and starting over with a design that doesn't have multiple threads touching shared state ;).

If you're volunteering to do the work... :)

@iamcodemaker
Copy link
Contributor Author

What would be involved in a rewrite like this? How feasible is doing something like that?

@rryan
Copy link
Member

rryan commented Nov 6, 2018

If you're volunteering to do the work... :)

I am!

@rryan
Copy link
Member

rryan commented Nov 6, 2018

What would be involved in a rewrite like this? How feasible is doing something like that?

A metric crap-tonne of work, in my estimation ;).

@ywwg
Copy link
Member

ywwg commented Nov 6, 2018

snapshotting controlobject state at the start of every audio callback?? 🙇‍♂️

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.

5 participants