LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
8.18k stars 1.01k forks source link

Qt5: crash when removing a channel that sends to another channel #2667

Closed Umcaruje closed 8 years ago

Umcaruje commented 8 years ago

Steps to reproduce:

  1. Open up a new project
  2. In the default TripleOscillator enter a random melody pattern and loop it
  3. Press Play
  4. Add 2 FX channels
  5. Route the instrument to FX1 and send FX1 to FX2
  6. Remove FX1
  7. LMMS crashes.

Version info:

Version 1.1.90-gef2cb53 (Linux/x86_64, Qt 5.2.1, GCC 4.8.4)

Backtrace:

*** Error in `/home/umcaruje/lmmsfork/buildqt5/lmms': malloc(): memory corruption (fast): 0x00000000027b5dcf ***

Program received signal SIGABRT, Aborted.
0x00007ffff3fcdcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt full
#0  0x00007ffff3fcdcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
        resultvar = 0
        pid = 14652
        selftid = 14652
#1  0x00007ffff3fd10d8 in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0xffffcf00, sa_sigaction = 0xffffcf00}, sa_mask = {__val = {39263824, 140737488342800, 5276323, 140737488342928, 
              27305400, 140737488342832, 140737329503852, 241407575, 140737488342944, 140737488343712, 140737329413847, 140737488342880, 5276323, 40573376, 27305400, 
              140737488342912}}, sa_flags = -158851476, sa_restorer = 0x7fffffffcfa0}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007ffff400a394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff4118b28 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
        ap = {{gp_offset = 40, fp_offset = 32767, overflow_arg_area = 0x7fffffffd200, reg_save_area = 0x7fffffffd190}}
        fd = 23
        on_2 = <optimized out>
        list = <optimized out>
        nlist = <optimized out>
        cp = <optimized out>
        written = <optimized out>
#3  0x00007ffff40150f7 in malloc_printerr (action=<optimized out>, str=0x7ffff4118ec8 "malloc(): memory corruption (fast)", ptr=<optimized out>) at malloc.c:4996
        buf = "00000000027b5dcf"
        cp = <optimized out>
#4  0x00007ffff4017e04 in _int_malloc (av=0x7ffff4355760 <main_arena>, bytes=4) at malloc.c:3359
        p = 0x0
        fb = <optimized out>
        pp = <optimized out>
        nb = 32
        idx = <optimized out>
        bin = <optimized out>
        victim = <optimized out>
        size = <optimized out>
        victim_index = <optimized out>
        remainder = <optimized out>
        remainder_size = <optimized out>
        block = <optimized out>
        bit = <optimized out>
        map = <optimized out>
        fwd = <optimized out>
---Type <return> to continue, or q <return> to quit---
        bck = <optimized out>
        errstr = <optimized out>
        __func__ = "_int_malloc"
#5  0x00007ffff40197b0 in __GI___libc_malloc (bytes=4) at malloc.c:2891
        ar_ptr = 0x7ffff4355760 <main_arena>
        victim = 0x6
        __func__ = "__libc_malloc"
#6  0x00007ffff46c0dad in operator new(unsigned long) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
No symbol table info available.
#7  0x00007ffff69453d8 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#8  0x00007ffff693df43 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#9  0x00007ffff693e1b2 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#10 0x00007ffff6943188 in QMdiSubWindow::eventFilter(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#11 0x00007ffff777de53 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#12 0x00007ffff67dac6c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#13 0x00007ffff67dfe56 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#14 0x00007ffff777dc2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#15 0x00007ffff777fe07 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#16 0x00007ffff77cacd3 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#17 0x00007ffff3136bd4 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#18 0x00007ffff3136e18 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#19 0x00007ffff3136ebc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#20 0x00007ffff77ca98c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#21 0x00007ffff777c96b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#22 0x00007ffff77830e1 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#23 0x00000000004ed3d6 in main (argc=1, argv=0x7fffffffde48) at ../src/core/main.cpp:807
        sparam = {__sched_priority = 50}
        ret = 32767
        fileToImport = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        app = 0x98d860
        os = {samplerate = 44100, vbr = false, bitrate = 160, depth = ProjectRenderer::Depth_16Bit}
        eff = ProjectRenderer::WaveFile
        fileToLoad = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        exitAfterImport = false
        allowRoot = false
        renderLoop = false
        renderTracks = false
        profilerOutputFile = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        qs = {interpolation = Mixer::qualitySettings::Interpolation_SincFastest, oversampling = Mixer::qualitySettings::Oversampling_2x}
        coreOnly = false
        fullscreen = true
        renderOut = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        pos = {static null = {<No data fields>}, d = 0x9e99e0}
Fastigium commented 8 years ago

It's interesting that this one should be Qt5-specific. Does it only occur when playing?

tresf commented 8 years ago

It's interesting that this one should be Qt5-specific

It's not.

Reproduced on both Qt5 and Qt4 builds.

Fastigium commented 8 years ago

Reproduced on both Qt5 and Qt4 builds

That's what I would expect, which is why I found it interesting that Umcaruje stated it was Qt5-specific (here). Anyway, my plan is to refactor deleting FX channels so that the actual deletion happens between mixer rounds (kinda like adding and removing PlayHandles is done right now). Crash-free deletion during a mixer round would require lots of checks everywhere and probably synchronization, too.

Umcaruje commented 8 years ago

Reproduced on both Qt5 and Qt4 builds.

That's weird, I can't reproduce this on my Qt4 build...

@Fastigium I just checked and this happens even without playing. I got an even longer backtrace when there is no playing:

QMutex: destroying locked mutex
*** Error in `/home/umcaruje/lmmsfork/buildqt5/lmms': malloc(): memory corruption (fast): 0x0000000002667cdf ***

Program received signal SIGABRT, Aborted.
0x00007ffff3fcdcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt full
#0  0x00007ffff3fcdcc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
        resultvar = 0
        pid = 4245
        selftid = 4245
#1  0x00007ffff3fd10d8 in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x1ab00000054, sa_sigaction = 0x1ab00000054}, sa_mask = {__val = {140737290524512, 64, 8, 40, 24, 0, 36169168, 
              27224416, 140737084809048, 17186444096, 1, 0, 140737084809136, 140737488338352, 140737084809048, 22260999935}}, sa_flags = -403546192, 
          sa_restorer = 0x7fffffffbe1c}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007ffff400a394 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff4118b28 "*** Error in `%s': %s: 0x%s ***\n")
    at ../sysdeps/posix/libc_fatal.c:175
        ap = {{gp_offset = 40, fp_offset = 0, overflow_arg_area = 0x7fffffffc020, reg_save_area = 0x7fffffffbfb0}}
        fd = 23
        on_2 = <optimized out>
        list = <optimized out>
        nlist = <optimized out>
        cp = <optimized out>
        written = <optimized out>
#3  0x00007ffff40150f7 in malloc_printerr (action=<optimized out>, str=0x7ffff4118ec8 "malloc(): memory corruption (fast)", ptr=<optimized out>) at malloc.c:4996
        buf = "0000000002667cdf"
        cp = <optimized out>
#4  0x00007ffff4017e04 in _int_malloc (av=0x7ffff4355760 <main_arena>, bytes=16) at malloc.c:3359
        p = 0x0
        fb = <optimized out>
        pp = <optimized out>
        nb = 32
        idx = <optimized out>
        bin = <optimized out>
        victim = <optimized out>
        size = <optimized out>
        victim_index = <optimized out>
        remainder = <optimized out>
        remainder_size = <optimized out>
        block = <optimized out>
        bit = <optimized out>
        map = <optimized out>
        fwd = <optimized out>
---Type <return> to continue, or q <return> to quit---
        bck = <optimized out>
        errstr = <optimized out>
        __func__ = "_int_malloc"
#5  0x00007ffff40197b0 in __GI___libc_malloc (bytes=16) at malloc.c:2891
        ar_ptr = 0x7ffff4355760 <main_arena>
        victim = 0x6
        __func__ = "__libc_malloc"
#6  0x00007fffeda6de42 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
No symbol table info available.
#7  0x00007fffeda6bdd7 in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
No symbol table info available.
#8  0x00007fffeda6d3ff in ?? () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
No symbol table info available.
#9  0x00007fffeda6d512 in xcb_wait_for_reply () from /usr/lib/x86_64-linux-gnu/libxcb.so.1
No symbol table info available.
#10 0x00007fffe762598e in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
No symbol table info available.
#11 0x00007ffff682a600 in QApplication::topLevelAt(QPoint const&) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#12 0x00007ffff67d8e76 in QApplication::widgetAt(QPoint const&) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#13 0x00007ffff67ded52 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#14 0x00007ffff683296a in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#15 0x00007ffff68349bb in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#16 0x00007ffff67dac8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#17 0x00007ffff67dfe56 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#18 0x00007ffff777dc2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#19 0x00007ffff6faa25c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
No symbol table info available.
#20 0x00007ffff6fab925 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#21 0x00007ffff6f94858 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
No symbol table info available.
#22 0x00007fffe763c5b0 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
No symbol table info available.
#23 0x00007ffff3136bd4 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#24 0x00007ffff3136e18 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#25 0x00007ffff3136ebc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#26 0x00007ffff77ca98c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#27 0x00007ffff777c96b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#28 0x00007ffff694eea8 in QMenu::exec(QPoint const&, QAction*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#29 0x0000000000608e91 in FxLine::contextMenuEvent (this=0x1f9f9d0) at ../src/gui/widgets/FxLine.cpp:227
        mix = 0xecab40
        contextMenu = {wp = {d = 0x272f4f0, value = 0x2631fe0}}
#30 0x00007ffff68166e9 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#31 0x00007ffff67dac8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#32 0x00007ffff67e173e in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#33 0x00007ffff777dc2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#34 0x00007ffff68333c6 in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#35 0x00007ffff68349bb in ?? () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#36 0x00007ffff67dac8c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#37 0x00007ffff67dfe56 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
No symbol table info available.
#38 0x00007ffff777dc2d in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#39 0x00007ffff6faa25c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
No symbol table info available.
#40 0x00007ffff6fab925 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) ()
   from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
No symbol table info available.
#41 0x00007ffff6f94858 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
No symbol table info available.
#42 0x00007fffe763c5b0 in ?? () from /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
No symbol table info available.
#43 0x00007ffff3136bd4 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#44 0x00007ffff3136e18 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#45 0x00007ffff3136ebc in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#46 0x00007ffff77ca98c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#47 0x00007ffff777c96b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#48 0x00007ffff77830e1 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
No symbol table info available.
#49 0x00000000004ed3d6 in main (argc=1, argv=0x7fffffffde48) at ../src/core/main.cpp:807
        sparam = {__sched_priority = 50}
        ret = 32767
        fileToImport = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        app = 0x98d860
        os = {samplerate = 44100, vbr = false, bitrate = 160, depth = ProjectRenderer::Depth_16Bit}
        eff = ProjectRenderer::WaveFile
        fileToLoad = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        exitAfterImport = false
        allowRoot = false
        renderLoop = false
        renderTracks = false
        profilerOutputFile = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
        qs = {interpolation = Mixer::qualitySettings::Interpolation_SincFastest, oversampling = Mixer::qualitySettings::Oversampling_2x}
        coreOnly = false
        fullscreen = true
        renderOut = {static null = {<No data fields>}, d = 0x7ffff7817660 <QArrayData::shared_null>}
---Type <return> to continue, or q <return> to quit---
        pos = {static null = {<No data fields>}, d = 0x9e9560}
Fastigium commented 8 years ago

That's a rather impressive backtrace :astonished:. Should still be fixed by the refactoring I proposed, though. I'll see if I can do that in the upcoming week. Wrestling with C++11 and Travis for now.

IvanMaldonado commented 8 years ago

Umcaruje I can, this happens to me as well on Qt4

Umcaruje commented 8 years ago

How can't I reproduce it on my Qt4 build scratches head\

tresf commented 8 years ago

@Umcaruje mine was on Mac build I tested on (since I didn't have a Qt4 Linux build handy at that moment).

Fastigium commented 8 years ago

PR to fix this available at #2675, testing welcome!

DeRobyJ commented 8 years ago

Any build I can test on win 7?

Fastigium commented 8 years ago

@DeRobyJ Here you go, although if you get a crash, it's not going to be trivial to get a backtrace. Still, if you can describe what you did when it happened, that might help :)

DeRobyJ commented 8 years ago

Fixed to me, did a bunch of tests, like deleting multiple channels with "unused" feature, or a channel sending to more than one other channel, and so on.

Win7 sp1 64bit

In fact, there is a problem. Plugins do not change their FX strip even if the numberbox changes. I mean: I opened an old project with 3 instrument in 3 different channels.

They keep their initial status, so on a black project everything will go to master, you can't change that.

Channel selecting works fine in lmms-1.1.90.1-g67334a8-win64-qt5

edit: Wait, aren't we testing a bug that came with qt5? That build is in qt 4.8.7!

Fastigium commented 8 years ago

@DeRobyJ Glad that it fixed the crashes! And I think I know what causes the issue you describe, I'll try to reproduce and fix it.

Fastigium commented 8 years ago

@DeRobyJ Another build, and the problem you mentioned should be fixed now. There is a small chance that the fix introduced other problems, so if you could test again, I'd be much obliged!

tresf commented 8 years ago

FYI, the linked build is Qt4, not Qt5. :+1:

DeRobyJ commented 8 years ago

That build seems fine, fixed the bug and I'm not getting anything bad, but that is in qt4!!

Fastigium commented 8 years ago

@DeRobyJ And here's a Qt5 build to complete the testing. I hope it works, building it involved some guesswork and some doubtful warnings.

@tresf The wiki page doesn't seem to contain any instructions on building for Windows with Qt5. I consulted the .travis files to get it done for now, but I'm not sure I did it right. What's the deal with Qt5 linguist not being there, in Travis builds as well? And I also got a ton of warnings about Policy CMP0020 is not set.

DeRobyJ commented 8 years ago

Ok, same behaviour. it doesn't crash when deleting or moving channels that send to others. Instruments can be routed to channels, so everything fine here.

Fastigium commented 8 years ago

@DeRobyJ Awesome, thanks for testing!