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

Fix crash in ControllerEngine::gracefulShutdown() #2767

Merged
merged 2 commits into from
May 10, 2020
Merged

Fix crash in ControllerEngine::gracefulShutdown() #2767

merged 2 commits into from
May 10, 2020

Conversation

uklotzde
Copy link
Contributor

@uklotzde uklotzde commented May 9, 2020

This fixes crash caused by invalid iterator usage when shutting down Mixxx while a controller is connected.

But afterwards Mixxx still crashes when exiting the Controller thread:

Debug [Controller]: Deleting USB Bulk devices...
Debug [Controller]: Deleting HID devices...
[Thread 0x7ffec3fff700 (LWP 22012) exited]
malloc_consolidate(): invalid chunk size

Thread 34 "Controller" received signal SIGABRT, Aborted.
[Switching to Thread 0x7ffee2ffd700 (LWP 22006)]
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	  return ret;
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff3623895 in __GI_abort () at abort.c:79
#2  0x00007ffff367e8c7 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff378fe1d "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007ffff3685dec in malloc_printerr (str=str@entry=0x7ffff37920a0 "malloc_consolidate(): invalid chunk size") at malloc.c:5347
#4  0x00007ffff3686cb8 in malloc_consolidate (av=av@entry=0x7ffff37c19e0 <main_arena>) at malloc.c:4477
#5  0x00007ffff3687460 in _int_free (av=0x7ffff37c19e0 <main_arena>, p=0x17057f0, have_lock=<optimized out>) at malloc.c:4400
#6  0x00007ffff63fb5bb in magazine_cache_push_magazine () at /lib64/libglib-2.0.so.0
#7  0x00007ffff63fb6cf in private_thread_memory_cleanup () at /lib64/libglib-2.0.so.0
#8  0x00007ffff37d1251 in __nptl_deallocate_tsd () at pthread_create.c:301
#9  __nptl_deallocate_tsd () at pthread_create.c:250
#10 0x00007ffff37d1445 in start_thread (arg=<optimized out>) at pthread_create.c:488
#11 0x00007ffff36ff9d3 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

@uklotzde uklotzde added this to the 2.3.0 milestone May 9, 2020
@uklotzde uklotzde mentioned this pull request May 9, 2020
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Thank you for the fix.

Only one minor comment.

src/controllers/controllerengine.cpp Outdated Show resolved Hide resolved
@Be-ing
Copy link
Contributor

Be-ing commented May 9, 2020

Is this a regression in 2.3? Does it also apply to the 2.2 branch? I have not noticed this bug.

@Be-ing Be-ing removed the blocker label May 9, 2020
@Be-ing
Copy link
Contributor

Be-ing commented May 9, 2020

I cannot reproduce this bug, so I am removing the "beta blocker" tag. Of course we should still fix this promptly, but I don't think there's a need to keep pushing back the beta even further.

@uklotzde
Copy link
Contributor Author

The iteration was plain wrong already in 2.2. Not sure when this undefined behavior actually caused an error. It might depend on both the Qt and compiler version.

@uklotzde
Copy link
Contributor Author

Iterators become dangling after removing/erasing items:
https://doc.qt.io/qt-5/qhash-iterator.html

@daschuer
Copy link
Member

LGTM, waiting for CI. Thank you.

@daschuer daschuer merged commit e164254 into mixxxdj:2.3 May 10, 2020
@uklotzde uklotzde deleted the controllerengine_shutdown branch May 10, 2020 12:40
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.

3 participants