LMMS / lmms

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

LMMS process keeps running (master) #4668

Open karmux opened 6 years ago

karmux commented 6 years ago

On master branch LMMS process keeps running after exit. I just open and close LMMS without loading any project. I'm using Manjaro Linux and SDL audio interface. This doesn't happen in stable-1.2 branch. Also this doesn't happen with PulseAudio in master branch. gdb doesn't show anything useful.

PhysSong commented 6 years ago

Do you have a backtrace?

karmux commented 6 years ago

Unfortunately it doesn't produce any traceback. gdb shows only this:

(gdb) run
Starting program: /home/karmux/lmms/build/lmms 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
*** WEAK-JACK: initializing
*** WEAK-JACK: OK. (0)
[New Thread 0x7fffeea71700 (LWP 10376)]
[New Thread 0x7fffe6d9a700 (LWP 10377)]
Notice: could not set realtime priority.
[New Thread 0x7fffdfdf5700 (LWP 10378)]
[New Thread 0x7fffde990700 (LWP 10379)]
[New Thread 0x7fffde18f700 (LWP 10380)]
[New Thread 0x7fffdd98e700 (LWP 10381)]
VST sync support disabled in your configuration
convolution: samplerate mismatch preset:48000 host:44100
convolution: samplerate mismatch preset:48000 host:44100
convolution: samplerate mismatch preset:48000 host:44100
convolution: samplerate mismatch preset:48000 host:44100
convolution: samplerate mismatch preset:48000 host:44100
convolution: samplerate mismatch preset:48000 host:44100
[New Thread 0x7fffcc191700 (LWP 10383)]
[New Thread 0x7fff93fff700 (LWP 10384)]
[New Thread 0x7fff937fe700 (LWP 10385)]
[New Thread 0x7fff92ffd700 (LWP 10386)]
[New Thread 0x7fff927fc700 (LWP 10387)]
[Thread 0x7fff927fc700 (LWP 10387) exited]
[Thread 0x7fffde18f700 (LWP 10380) exited]
[Thread 0x7fffde990700 (LWP 10379) exited]
[Thread 0x7fffdd98e700 (LWP 10381) exited]
^C (it was stopping here and I had to Ctrl + C)
Thread 1 "lmms" received signal SIGINT, Interrupt.
0x00007ffff7f71f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0
(gdb) Quit
(gdb) quit
A debugging session is active.

        Inferior 1 [process 10372] will be killed.

Quit anyway? (y or n) y
PhysSong commented 6 years ago

@karmux You can try thread apply all bt after pressing Ctrl + C. Also, do you use SDL1 or SDL2?

karmux commented 6 years ago
Click to expand ``` (gdb) thread apply all bt Thread 11 (Thread 0x7fff92ffd700 (LWP 32012)): #0 0x00007ffff5049c21 in poll () from /usr/lib/libc.so.6 #1 0x000055555577c10d in MidiAlsaSeq::run (this=0x555555ff7430) at /home/karmux/lmms/src/core/midi/MidiAlsaSeq.cpp:472 #2 0x00007ffff5389f65 in ?? () from /usr/lib/libQt5Core.so.5 #3 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #4 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 10 (Thread 0x7fff937fe700 (LWP 32011)): #0 0x00007ffff5049d16 in ppoll () from /usr/lib/libc.so.6 #1 0x00007ffff704da13 in pa_mainloop_poll () from /usr/lib/libpulse.so.0 #2 0x00007ffff704dfe0 in pa_mainloop_iterate () from /usr/lib/libpulse.so.0 #3 0x00007ffff756bf48 in ?? () from /usr/lib/libSDL2-2.0.so.0 #4 0x00007ffff74c8016 in ?? () from /usr/lib/libSDL2-2.0.so.0 #5 0x00007ffff750c60f in ?? () from /usr/lib/libSDL2-2.0.so.0 #6 0x00007ffff758d2ca in ?? () from /usr/lib/libSDL2-2.0.so.0 #7 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #8 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 9 (Thread 0x7fff93fff700 (LWP 32010)): #0 0x00007ffff5049d16 in ppoll () from /usr/lib/libc.so.6 #1 0x00007ffff704da13 in pa_mainloop_poll () from /usr/lib/libpulse.so.0 #2 0x00007ffff704dfe0 in pa_mainloop_iterate () from /usr/lib/libpulse.so.0 #3 0x00007ffff756c187 in ?? () from /usr/lib/libSDL2-2.0.so.0 #4 0x00007ffff74c6e56 in ?? () from /usr/lib/libSDL2-2.0.so.0 #5 0x00007ffff750c60f in ?? () from /usr/lib/libSDL2-2.0.so.0 #6 0x00007ffff758d2ca in ?? () from /usr/lib/libSDL2-2.0.so.0 #7 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #8 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 8 (Thread 0x7fffcc196700 (LWP 32009)): #0 0x00007ffff5049d16 in ppoll () from /usr/lib/libc.so.6 #1 0x00007ffff704da13 in pa_mainloop_poll () from /usr/lib/libpulse.so.0 #2 0x00007ffff704dfe0 in pa_mainloop_iterate () from /usr/lib/libpulse.so.0 #3 0x00007ffff704e091 in pa_mainloop_run () from /usr/lib/libpulse.so.0 #4 0x00007ffff756c2f0 in ?? () from /usr/lib/libSDL2-2.0.so.0 #5 0x00007ffff750c60f in ?? () from /usr/lib/libSDL2-2.0.so.0 #6 0x00007ffff758d2ca in ?? () from /usr/lib/libSDL2-2.0.so.0 #7 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #8 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 4 (Thread 0x7fffdfdf5700 (LWP 32005)): #0 0x00007ffff7f76afc in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0 #1 0x00007fffe44841ac in ?? () from /usr/lib/dri/i965_dri.so #2 0x00007fffe4483ee8 in ?? () from /usr/lib/dri/i965_dri.so #3 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #4 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 3 (Thread 0x7fffe6d9a700 (LWP 32004)): #0 0x00007ffff5049c21 in poll () from /usr/lib/libc.so.6 #1 0x00007ffff3fd4ee0 in ?? () from /usr/lib/libglib-2.0.so.0 #2 0x00007ffff3fd4fce in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0 #3 0x00007ffff558afc9 in QEventDispatcherGlib::processEvents(QFlags) () from /usr/lib/libQt5Core.so.5 #4 0x00007ffff55368cc in QEventLoop::exec(QFlags) () from /usr/lib/libQt5Core.so.5 #5 0x00007ffff537feb9 in QThread::exec() () from /usr/lib/libQt5Core.so.5 #6 0x00007ffff0190ba6 in ?? () from /usr/lib/libQt5DBus.so.5 #7 0x00007ffff5389f65 in ?? () from /usr/lib/libQt5Core.so.5 #8 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #9 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 2 (Thread 0x7fffeea71700 (LWP 32003)): #0 0x00007ffff5049c21 in poll () from /usr/lib/libc.so.6 #1 0x00007ffff3b90630 in ?? () from /usr/lib/libxcb.so.1 #2 0x00007ffff3b922db in xcb_wait_for_event () from /usr/lib/libxcb.so.1 #3 0x00007ffff0295c5a in ?? () from /usr/lib/libQt5XcbQpa.so.5 --Type for more, q to quit, c to continue without paging-- #4 0x00007ffff5389f65 in ?? () from /usr/lib/libQt5Core.so.5 #5 0x00007ffff7f70a9d in start_thread () from /usr/lib/libpthread.so.0 #6 0x00007ffff5054b23 in clone () from /usr/lib/libc.so.6 Thread 1 (Thread 0x7ffff0a7d800 (LWP 31999)): #0 0x00007ffff7f71f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0 #1 0x00007ffff750c7f7 in ?? () from /usr/lib/libSDL2-2.0.so.0 #2 0x00007ffff74c6f03 in ?? () from /usr/lib/libSDL2-2.0.so.0 #3 0x0000555555778ff3 in AudioSdl::~AudioSdl (this=0x555555da29e0, __in_chrg=) at /home/karmux/lmms/src/core/audio/AudioSdl.cpp:129 #4 0x0000555555779062 in AudioSdl::~AudioSdl (this=0x555555da29e0, __in_chrg=) at /home/karmux/lmms/src/core/audio/AudioSdl.cpp:140 #5 0x000055555571c0ee in Mixer::~Mixer (this=0x555555cdfc10, __in_chrg=) at /home/karmux/lmms/src/core/Mixer.cpp:189 #6 0x000055555571c2be in Mixer::~Mixer (this=0x555555cdfc10, __in_chrg=) at /home/karmux/lmms/src/core/Mixer.cpp:201 #7 0x00005555556f5bbe in LmmsCore::deleteHelper (ptr=0x5555559d6830 ) at /home/karmux/lmms/include/Engine.h:126 #8 0x00005555556f5595 in LmmsCore::destroy () at /home/karmux/lmms/src/core/Engine.cpp:94 #9 0x00005555557b6d95 in MainWindow::~MainWindow (this=0x555555fea8a0, __in_chrg=) at /home/karmux/lmms/src/gui/MainWindow.cpp:260 #10 0x00005555557b6e0c in MainWindow::~MainWindow (this=0x555555fea8a0, __in_chrg=) at /home/karmux/lmms/src/gui/MainWindow.cpp:261 #11 0x00007ffff5562371 in QObject::event(QEvent*) () from /usr/lib/libQt5Core.so.5 #12 0x00007ffff7a9db0c in QWidget::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5 #13 0x00007ffff7ba9445 in QMainWindow::event(QEvent*) () from /usr/lib/libQt5Widgets.so.5 #14 0x00007ffff7a5de14 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #15 0x00007ffff7a656e1 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/libQt5Widgets.so.5 #16 0x00007ffff5537c39 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/libQt5Core.so.5 #17 0x00007ffff553accc in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () from /usr/lib/libQt5Core.so.5 #18 0x00007ffff558b9d4 in ?? () from /usr/lib/libQt5Core.so.5 #19 0x00007ffff3fd33cf in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0 #20 0x00007ffff3fd4f89 in ?? () from /usr/lib/libglib-2.0.so.0 #21 0x00007ffff3fd4fce in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0 #22 0x00007ffff558afc9 in QEventDispatcherGlib::processEvents(QFlags) () from /usr/lib/libQt5Core.so.5 #23 0x00007ffff032be12 in ?? () from /usr/lib/libQt5XcbQpa.so.5 #24 0x00007ffff55368cc in QEventLoop::exec(QFlags) () from /usr/lib/libQt5Core.so.5 #25 0x00007ffff553ebc6 in QCoreApplication::exec() () from /usr/lib/libQt5Core.so.5 #26 0x00005555556b535b in main (argc=1, argv=0x7fffffffe3b8) at /home/karmux/lmms/src/core/main.cpp:919 ```
PhysSong commented 6 years ago

I can reproduce this with SDL2. The hang happens randomly, but LMMS almost always hang when closing after loading unfa-Spoken.mmpz. It seems like SDL is waiting for its PulseAudio thread. I'm not sure if something is wrong on LMMS' side. Unfortunately, I was unable to trigger the hang with a debug build of SDL2.

wolfram-omega commented 5 years ago

Same problem for me, every time I close LMMS. A backtrace with debug builds for sdl2 and pulseaudio:

Click to expand ``` (gdb) thread apply all bt Thread 10 (Thread 0x7fff97fff700 (LWP 13967)): #0 0x00007ffff59c5d16 in ppoll () at /usr/lib/libc.so.6 #1 0x00007ffff7627c13 in ppoll (__ss=0x0, __timeout=, __nfds=, __fds=) at /usr/include/bits/poll2.h:77 #2 0x00007ffff7627c13 in pa_mainloop_poll (m=m@entry=0x5555561786a0) at pulse/mainloop.c:852 #3 0x00007ffff76281e0 in pa_mainloop_iterate (m=0x5555561786a0, block=, retval=0x0) at pulse/mainloop.c:926 #4 0x00007ffff774f608 in PULSEAUDIO_FlushCapture (this=0x5555561785c0) at /usr/src/debug/SDL2-2.0.9/src/audio/pulseaudio/SDL_pulseaudio.c:429 #5 0x00007ffff76a81ba in SDL_CaptureAudio (devicep=devicep@entry=0x5555561785c0) at /usr/src/debug/SDL2-2.0.9/src/audio/SDL_audio.c:814 #6 0x00007ffff76edfaf in SDL_RunThread (data=0x555556185760) at /usr/src/debug/SDL2-2.0.9/src/thread/SDL_thread.c:283 #7 0x00007ffff77716ea in RunThread (data=) at /usr/src/debug/SDL2-2.0.9/src/thread/pthread/SDL_systhread.c:78 #8 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #9 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 9 (Thread 0x7fffe0c01700 (LWP 13966)): #0 0x00007ffff59c5d16 in ppoll () at /usr/lib/libc.so.6 #1 0x00007ffff7627c13 in ppoll (__ss=0x0, __timeout=, __nfds=, __fds=) at /usr/include/bits/poll2.h:77 #2 0x00007ffff7627c13 in pa_mainloop_poll (m=m@entry=0x55555616b930) at pulse/mainloop.c:852 #3 0x00007ffff76281e0 in pa_mainloop_iterate (m=0x55555616b930, block=, retval=0x0) at pulse/mainloop.c:926 #4 0x00007ffff774f847 in PULSEAUDIO_WaitDevice (this=0x55555616b850) at /usr/src/debug/SDL2-2.0.9/src/audio/pulseaudio/SDL_pulseaudio.c:340 #5 0x00007ffff76a7046 in SDL_RunAudio (devicep=devicep@entry=0x55555616b850) at /usr/src/debug/SDL2-2.0.9/src/audio/SDL_audio.c:756 #6 0x00007ffff76edfaf in SDL_RunThread (data=0x555556178370) at /usr/src/debug/SDL2-2.0.9/src/thread/SDL_thread.c:283 #7 0x00007ffff77716ea in RunThread (data=) at /usr/src/debug/SDL2-2.0.9/src/thread/pthread/SDL_systhread.c:78 #8 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #9 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 8 (Thread 0x7fffe0c4c700 (LWP 13965)): #0 0x00007ffff59c5d16 in ppoll () at /usr/lib/libc.so.6 #1 0x00007ffff7627c13 in ppoll (__ss=0x0, __timeout=, __nfds=, __fds=) at /usr/include/bits/poll2.h:77 #2 0x00007ffff7627c13 in pa_mainloop_poll (m=m@entry=0x5555561506b0) at pulse/mainloop.c:852 #3 0x00007ffff76281e0 in pa_mainloop_iterate (m=0x5555561506b0, block=, retval=0x0) at pulse/mainloop.c:926 #4 0x00007ffff7628291 in pa_mainloop_run (m=0x5555561506b0, retval=0x0) at pulse/mainloop.c:945 #5 0x00007ffff774f9b0 in HotplugThread (data=data@entry=0x0) at /usr/src/debug/SDL2-2.0.9/src/audio/pulseaudio/SDL_pulseaudio.c:718 #6 0x00007ffff76edfaf in SDL_RunThread (data=0x55555602a3e0) at /usr/src/debug/SDL2-2.0.9/src/thread/SDL_thread.c:283 #7 0x00007ffff77716ea in RunThread (data=) at /usr/src/debug/SDL2-2.0.9/src/thread/pthread/SDL_systhread.c:78 #8 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #9 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 --Type for more, q to quit, c to continue without paging--c Thread 6 (Thread 0x7fffe2d59700 (LWP 13963)): #0 0x00007ffff59c5c21 in poll () at /usr/lib/libc.so.6 #1 0x00007ffff4c8f690 in () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff4c8f77e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff5f12c99 in QEventDispatcherGlib::processEvents(QFlags) () at /usr/lib/libQt5Core.so.5 #4 0x00007ffff5ebba8c in QEventLoop::exec(QFlags) () at /usr/lib/libQt5Core.so.5 #5 0x00007ffff5cff569 in QThread::exec() () at /usr/lib/libQt5Core.so.5 #6 0x00007ffff20efba6 in () at /usr/lib/libQt5DBus.so.5 #7 0x00007ffff5d0096c in () at /usr/lib/libQt5Core.so.5 #8 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #9 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 5 (Thread 0x7fffe355a700 (LWP 13962)): #0 0x00007ffff7f75afc in pthread_cond_wait@@GLIBC_2.3.2 () at /usr/lib/libpthread.so.0 #1 0x00007fffe37ac254 in () at /usr/lib/dri/i965_dri.so #2 0x00007fffe37abf78 in () at /usr/lib/dri/i965_dri.so #3 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #4 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 4 (Thread 0x7fffeaa6f700 (LWP 13961)): #0 0x00007ffff59c5c21 in poll () at /usr/lib/libc.so.6 #1 0x00007ffff4c8f690 in () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff4c906d2 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0 #3 0x00007fffeb9f9568 in () at /usr/lib/libgio-2.0.so.0 #4 0x00007ffff4c6ac21 in () at /usr/lib/libglib-2.0.so.0 #5 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #6 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 3 (Thread 0x7fffeb270700 (LWP 13960)): #0 0x00007ffff59c5c21 in poll () at /usr/lib/libc.so.6 #1 0x00007ffff4c8f690 in () at /usr/lib/libglib-2.0.so.0 #2 0x00007ffff4c8f77e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0 #3 0x00007ffff4c8f7d2 in () at /usr/lib/libglib-2.0.so.0 #4 0x00007ffff4c6ac21 in () at /usr/lib/libglib-2.0.so.0 #5 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #6 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 2 (Thread 0x7ffff13b4700 (LWP 13959)): #0 0x00007ffff59c5c21 in poll () at /usr/lib/libc.so.6 #1 0x00007ffff498d630 in () at /usr/lib/libxcb.so.1 #2 0x00007ffff498f2db in xcb_wait_for_event () at /usr/lib/libxcb.so.1 #3 0x00007ffff221e989 in () at /usr/lib/libQt5XcbQpa.so.5 #4 0x00007ffff5d0096c in () at /usr/lib/libQt5Core.so.5 #5 0x00007ffff7f6fa9d in start_thread () at /usr/lib/libpthread.so.0 #6 0x00007ffff59d0b23 in clone () at /usr/lib/libc.so.6 Thread 1 (Thread 0x7ffff27bc800 (LWP 13955)): #0 0x00007ffff7f70f6d in __pthread_timedjoin_ex () at /usr/lib/libpthread.so.0 #1 0x00007ffff76ee337 in SDL_WaitThread_REAL (thread=0x555555ae84c0, status=status@entry=0x0) at /usr/src/debug/SDL2-2.0.9/src/thread/SDL_thread.c:471 #2 0x00007ffff76a70f7 in close_audio_device (device=0x5555561785c0) at /usr/src/debug/SDL2-2.0.9/src/audio/SDL_audio.c:1117 #3 0x000055555579c93f in AudioSdl::~AudioSdl() (this=0x55555606cfe0, __in_chrg=) at /home/wolfram/git_root/lmms/src/core/audio/AudioSdl.cpp:129 #4 0x000055555579c9ae in AudioSdl::~AudioSdl() (this=0x55555606cfe0, __in_chrg=) at /home/wolfram/git_root/lmms/src/core/audio/AudioSdl.cpp:140 #5 0x000055555573b1e9 in Mixer::~Mixer() (this=0x55555601fa90, __in_chrg=) at /home/wolfram/git_root/lmms/src/core/Mixer.cpp:190 #6 0x000055555573b384 in Mixer::~Mixer() (this=0x55555601fa90, __in_chrg=) at /home/wolfram/git_root/lmms/src/core/Mixer.cpp:201 #7 0x0000555555714d38 in LmmsCore::deleteHelper(Mixer**) (ptr=0x5555559e0930 ) at /home/wolfram/git_root/lmms/include/Engine.h:129 #8 0x00005555557146c1 in LmmsCore::destroy() () at /home/wolfram/git_root/lmms/src/core/Engine.cpp:96 #9 0x00005555557d6faf in MainWindow::~MainWindow() (this=0x555556186f20, __in_chrg=) at /home/wolfram/git_root/lmms/src/gui/MainWindow.cpp:260 #10 0x00005555557d7026 in MainWindow::~MainWindow() (this=0x555556186f20, __in_chrg=) at /home/wolfram/git_root/lmms/src/gui/MainWindow.cpp:261 #11 0x00007ffff5ee8121 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5 #12 0x00007ffff7a940dc in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5 #13 0x00007ffff7ba1535 in QMainWindow::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5 #14 0x00007ffff7a52e24 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5 #15 0x00007ffff7a5a5f1 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5 #16 0x00007ffff5ebcdf9 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5 #17 0x00007ffff5ebfee8 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) () at /usr/lib/libQt5Core.so.5 #18 0x00007ffff5f136c4 in () at /usr/lib/libQt5Core.so.5 #19 0x00007ffff4c8d7bf in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0 #20 0x00007ffff4c8f739 in () at /usr/lib/libglib-2.0.so.0 #21 0x00007ffff4c8f77e in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0 #22 0x00007ffff5f12c99 in QEventDispatcherGlib::processEvents(QFlags) () at /usr/lib/libQt5Core.so.5 #23 0x00007ffff5ebba8c in QEventLoop::exec(QFlags) () at /usr/lib/libQt5Core.so.5 #24 0x00007ffff5ec3de6 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5 #25 0x00005555556b555b in main(int, char**) (argc=1, argv=0x7fffffffe708) at /home/wolfram/git_root/lmms/src/core/main.cpp:972 ``` Looks like thread 1 is waiting forever for thread 10 to finish: ``` (gdb) p close_audio_device::device->thread->name $6 = 0x555556185740 "SDLAudioC3" (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff27bc800 (LWP 13955) "lmms" 0x00007ffff7f70f6d in __pthread_timedjoin_ex () from /usr/lib/libpthread.so.0 2 Thread 0x7ffff13b4700 (LWP 13959) "QXcbEventQueue" 0x00007ffff59c5c21 in poll () from /usr/lib/libc.so.6 3 Thread 0x7fffeb270700 (LWP 13960) "gmain" 0x00007ffff59c5c21 in poll () from /usr/lib/libc.so.6 4 Thread 0x7fffeaa6f700 (LWP 13961) "gdbus" 0x00007ffff59c5c21 in poll () from /usr/lib/libc.so.6 5 Thread 0x7fffe355a700 (LWP 13962) "lmms:disk$0" 0x00007ffff7f75afc in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0 6 Thread 0x7fffe2d59700 (LWP 13963) "QDBusConnection" 0x00007ffff59c5c21 in poll () from /usr/lib/libc.so.6 8 Thread 0x7fffe0c4c700 (LWP 13965) "PulseHotplug" 0x00007ffff59c5d16 in ppoll () from /usr/lib/libc.so.6 9 Thread 0x7fffe0c01700 (LWP 13966) "SDLAudioP2" 0x00007ffff59c5d16 in ppoll () from /usr/lib/libc.so.6 10 Thread 0x7fff97fff700 (LWP 13967) "SDLAudioC3" 0x00007ffff59c5d16 in ppoll () from /usr/lib/libc.so.6 ```

Is there any additional information you need?

PhysSong commented 5 years ago

After some investigation, I found some interesting facts.

However, I'm still not sure what can we do.

PhysSong commented 5 years ago

As @wolfram-omega's backtrace shows, it's related to the audio capture thread. If I comment out the call to Mixer::pushInputFrames() in AudioSdl::sdlInputAudioCallback(), LMMS doesn't hang anymore. @Reflexe Do you have any ideas here? I'm asking you because you are working on the recording stuff.

Reflexe commented 5 years ago

Ok, The problem is that SDL waits for the PulseAudio thread to exit but it won't quit for some reason. The strange thing is, that nothing is stuck on lmms side. I suspect it is an upstream bug.

firewall1110 commented 3 years ago

I found, that LMMS hung (on my Debian 10 system allways) on SDL destructor and with this "redaction"

AudioSdl::~AudioSdl()
{
    stopProcessing();

#ifdef LMMS_HAVE_SDL2
    //if (m_inputDevice != 0)
        //SDL_CloseAudioDevice(m_inputDevice);;
    if (m_outputDevice != 0)
        SDL_CloseAudioDevice(m_outputDevice);
#else
    SDL_CloseAudio();
    delete[] m_convertedBuf;
#endif

    //SDL_Quit();

    delete[] m_outBuf;
}

LMMS not hung more ...

firewall1110 commented 3 years ago

Some more information: If LMMS opened it terminal (with ./lmms), than lmms freeze is seen and hanging threads will not killled after <Ctrl + Z> pressed (after this it seems , that LMMS stoped, but threads are not closed - pstree shows this). This threads are removed from system if terminal is closed. It seems that AppImage use "bash sand-boxing" - no problems with AppImage. If LMMS (compiled version) is opened by double clicking, there is illusion that no problem but pstree shows , that hanging threads are attached to file manager and slows down LogOut/ShutDown/Restart process.

firewall1110 commented 3 years ago

(1) Experimenting with SDL2 I found that one lag in AudioSdl::sdlInputAudioCallback() will cause SDL2 hung on quit. And now I found when and there it's happens: Mixer.cpp ~305 line function requestChangeInModel(); waits when LMMS project is loading ~800 msec lag . (2) I found , that function supportsCapture() is used only in SongEditor.cpp and AudioPortAudio.cpp not in Mixer.cpp @ Co ... P.S. Is it normal, than GUI thread not wait other threads to quit , and not trying to do something, if some of them not quit - hung ?

firewall1110 commented 3 years ago

Minimalistic change in Mixer.cpp ~303 line:

void Mixer::pushInputFrames( sampleFrame * _ab, const f_cnt_t _frames )
{
    bool needCapture = Engine::getSong()->isRecording(); //new 
    if (needCapture) { requestChangeInModel(); } // changed

    f_cnt_t frames = m_inputBufferFrames[ m_inputBufferWrite ];
    int size = m_inputBufferSize[ m_inputBufferWrite ];
    sampleFrame * buf = m_inputBuffer[ m_inputBufferWrite ];

    if( frames + _frames > size )
    {
        size = qMax( size * 2, frames + _frames );
        sampleFrame * ab = new sampleFrame[ size ];
        memcpy( ab, buf, frames * sizeof( sampleFrame ) );
        delete [] buf;

        m_inputBufferSize[ m_inputBufferWrite ] = size;
        m_inputBuffer[ m_inputBufferWrite ] = ab;

        buf = ab;
    }

    memcpy( &buf[ frames ], _ab, _frames * sizeof( sampleFrame ) );
    m_inputBufferFrames[ m_inputBufferWrite ] += _frames;

    if (needCapture) { doneChangeInModel(); } //changed
}

And now there is no lag - and SDL quit without problems ...

Should I do PR?

qnebra commented 3 years ago

I think it is good idea. Any fix to lmms SDL perfomance will be good, as it is default backend in lmms.

firewall1110 commented 3 years ago

Thank You for answer! I'll make PR in 1 - 3 days . But "things are not so simple": requestChangeInModel(); and doneChangeInModel(); must not be called from audio processing call-back , but it seems that recording (and capture monitoring) is not implemented so implementation can not be tested - LMMS project is not ready for this; for performance reason capture call-back should not be on than is not needed (but needed only than recording/monitoring) - so needed some API to start/stop capture call-back; anyway once LMMS was hung (now only once - not always) - so need some work-around in GUI (its lol , but now I know why my computer sometimes shut down so slow - if GUI closes , normal user not see any problem with LMMS, but experience computer performance degradation without any idea what's happens ... ). My plan is: (A & B in parallel): A main (I know how implement now): (1) do changes to call requestChangeInModel(); and doneChangeInModel();only than recording; (2) do not start capture call-back on start but implement captureStart() and captureStop() functions as base class (it is AudioDevice) virtual functions and AudioSdl class implementation; and "connect" with partially implemented recording staff.
optional (I only have some ideas how to implement): (3) find way how to insert capture monitoring - this makes possible testing other driver capture (makes possible to implement this - now only AudioSdl has capture and AudioPulseAudio has some draft for this. B make GUI to control such situations and try to work around - the basic is make message to user that LMMS manual "killing" or computer restart is needed. But I have no idea how to implement this right now, but after A will be merged to master - will be problems to test something that not needed right now. Solution may be another PR with status "work in progress" after I find any minimal idea how to do this .

Key problem is - how to test?

firewall1110 commented 3 months ago

I think should be closed: already fixed (SDL2 never hung on current master)