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

Protect waveformmark.h's operator from causing segfaults #4781

Closed
wants to merge 4 commits into from
Closed

Protect waveformmark.h's operator from causing segfaults #4781

wants to merge 4 commits into from

Conversation

bencejuhaasz
Copy link

Every few hours while playing from a rekordbox usb, I got crashes because of this operator.
Checking for nullptr seems to fix the issue, I did a 5-6 hour test w/o any problem.
Not properly displaying hotcue tags seems to be a reasonable tradeoff to avoid a crash while playing live,
so I'm making a pull request. But if a simple 'false' is not the best return value, and we should check for the two marks separately, feel free to correct me.

I get a segfault here every few hours. What's happening ? Let's not call methods of waveformmarks if they are nullptr's as a dummy protection mechanism.
@uklotzde
Copy link
Contributor

uklotzde commented Jun 1, 2022

Welcome and thank you for deciding to contribute.

The fix is relevant for release 2.3. Please create a separate, local bugfix branch based on 2.3 for your changes and then submit a new pull requests. Reusing main or any release branch directly for this purpose is not recommended. Unfortunately, GitHub PRs are tight to their branch names, that's why a new PR would be required then.

I will add a code comment to this PR.

@bencejuhaasz
Copy link
Author

The crash doesn't happen in 2.3. It does in 2.4.

double rightPosition = rhs->getSamplePosition();
int rightHotcue = rhs->getHotCue();
if (leftPosition == rightPosition) {
//A segfault in here crashes the whole program for me every few hours. Let's make sure we aren't comparing null pointers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use VERIFY_OR_DEBUG_ASSERT(lhs) / VERIFY_OR_DEBUG_ASSERT(rhs) for each of the arguments followed by an early return. This is more readable and will also leave the remaining code unchanged.

Copy link
Contributor

Choose a reason for hiding this comment

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

The debug assertions will help to reveal situations in which this bug occurs and only stop Mixxx during development, before any user notices.

@uklotzde
Copy link
Contributor

uklotzde commented Jun 1, 2022

We also need your permission before merging any code. Please sign our Contributor Agreement.

@uklotzde
Copy link
Contributor

uklotzde commented Jun 1, 2022

The crash doesn't happen in 2.3. It does in 2.4.

Checking the pointers before dereferencing is still good practice and should also be added to 2.3. Just in case.

@uklotzde
Copy link
Contributor

uklotzde commented Jun 1, 2022

For more information about the Git workflow and dev tools for code formatting or the pre-commit checks please refer to CONTRIBUTING.md.

@uklotzde
Copy link
Contributor

uklotzde commented Jun 1, 2022

Have you enabled caching of waveform data? I have disabled it and never experienced such a crash.

@Swiftb0y
Copy link
Member

Swiftb0y commented Jun 1, 2022

IMO this is also just a workaround, knowing why these actually become nullptr would be much more interesting. Being able to catch that using VERIFY_OR_DEBUG_ASSERT would be a good first step towards that.

@bencejuhaasz
Copy link
Author

The segmentation fault is still occuring, seems like this quick fix is not enough:

Thread 1 "mixxx" received signal SIGSEGV, Segmentation fault.
__gnu_cxx::__ops::_Val_less_iter::operator()<QSharedPointer<WaveformMark>, QList<QSharedPointer<WaveformMark>>::iterator> (__it=...,   __val=<synthetic pointer>..., this=<synthetic pointer>) at /usr/include/c++/10/bits/predefined_ops.h:96

I don't know what to do with this, I'll probably just won't use waveform marks in my skin.

@Swiftb0y
Copy link
Member

Swiftb0y commented Jun 4, 2022

It would be great if you could run mixxx in a debugger to capture a backtrace for when these segfaults occur.
https://github.com/mixxxdj/mixxx/wiki/Creating%20Backtraces

@Swiftb0y
Copy link
Member

Swiftb0y commented Jun 4, 2022

I don't think the fault lies solely in the waveform marks, the culprit must be somewhere else. If you don't use any waveform marks, mixxx will probably just crash somewhere else.

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Sep 3, 2022
@JoergAtGithub
Copy link
Member

@bencejuhaasz This should be fixed by #11744 , can you test this please.
I close this PR in favor of #11744 therefore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues that haven't been updated for a long time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants