Skip to content

Conversation

@PhysSong
Copy link
Member

@PhysSong PhysSong commented Oct 23, 2017

While investigating #3897, I found another bug.
Steps to reproduce:

  1. Click any preset on sidebar and hold it.
  2. Close LMMS with Alt+F4 or Ctrl+Q(while previewing).
  3. LMMS will crash.

Edit: clarified steps to reproduce.

Here's a part of a backtrace:

Thread 1 (Thread 0x7ffff7ee1900 (LWP 11830)): #0 0x000000000053c74a in PresetPreviewPlayHandle::isFromTrack(Track const*) const () #1 0x0000000000526e8c in Mixer::removePlayHandlesOfTypes(Track*, unsigned char) () #2 0x00000000006275a7 in InstrumentTrack::silenceAllNotes(bool) () #3 0x000000000062c86d in InstrumentTrack::~InstrumentTrack() () #4 0x000000000062ca59 in InstrumentTrack::~InstrumentTrack() () #5 0x00000000005c54ba in TrackContainerView::clearAllTracks() () #6 0x0000000000552a5c in Song::clearProject() () #7 0x00000000004fc74f in LmmsCore::destroy() () 

So I added PlayHandle::TypePresetPreviewHandle in InstrumentTrack::silenceAllNotes(). I also add simple safety check code in PresetPreviewPlayHandle::isFromTrack().

Note: PresetPreviewPlayHandle::play() does nothing since #2586, so the code below is no longer needed. However, leaving it as-is looks fine for me.

if( m_previewPlayHandle != NULL )
{
if( !Engine::mixer()->addPlayHandle(
m_previewPlayHandle ) )
{
m_previewPlayHandle = NULL;
}
}

Edit: I added a commit which fixes #3456, per #3905 (comment).

@PhysSong PhysSong added this to the 1.2.0 milestone Oct 23, 2017
@gi0e5b06
Copy link

Bug confirmed and proposed fix working. Approved
(and applied to my branch)

@PhysSong PhysSong removed this from the 1.2.0 milestone Oct 24, 2017
@zonkmachine
Copy link
Contributor

I can't reproduce the bug on my machine. Linuxmint 17.3 at fbfcb43

@PhysSong
Copy link
Member Author

@zonkmachine I clarified the "steps to reproduce" section. I can confirm the issue with the same revision. Could you please test that again?

@zonkmachine
Copy link
Contributor

Ah, got it!

Bug verified. Testing the fix but it doesn't appear to shut down completely. Alt + F4.

Program received signal SIGINT, Interrupt. syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 38	../sysdeps/unix/sysv/linux/x86_64/syscall.S: No such file or directory. (gdb) bt full #0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38 No locals. #1 0x00007ffff6858dd3 in _q_futex (val2=0, addr2=0x0, timeout=0x0, val=2, op=0, addr=0xef6da0) at thread/qmutex_unix.cpp:99 No locals. #2 QMutexPrivate::wait (this=this@entry=0xef6da0, timeout=timeout@entry=-1) at thread/qmutex_unix.cpp:113 ts = {tv_sec = 140737488343808, tv_nsec = 1} pts = 0x0 timer = {t1 = 140737488343808, t2 = 27866800} #3 0x00007ffff6855275 in QMutex::lockInternal (this=<optimized out>) at thread/qmutex.cpp:450 maximumSpinTime = <optimized out> averageWaitTime = <optimized out> actualWaitTime = <optimized out> spinTime = 1000326 d = 0xef6da0 elapsedTimer = {t1 = 6344, t2 = 617602127} maximumSpinTime = <optimized out> spinTime = <optimized out> #4 0x000000000054b43a in PreviewTrackContainer::lockData (this=0xef6d20) at /home/zonkmachine/builds/lmms/lmms/src/core/PresetPreviewPlayHandle.cpp:79 No locals. #5 0x000000000054ad64 in PresetPreviewPlayHandle::~PresetPreviewPlayHandle (this=0x201c1a0, __in_chrg=<optimized out>) at /home/zonkmachine/builds/lmms/lmms/src/core/PresetPreviewPlayHandle.cpp:198 No locals. #6 0x000000000054adf4 in PresetPreviewPlayHandle::~PresetPreviewPlayHandle (this=0x201c1a0, __in_chrg=<optimized out>) at /home/zonkmachine/builds/lmms/lmms/src/core/PresetPreviewPlayHandle.cpp:207 No locals. 
@PhysSong
Copy link
Member Author

Okay. There is a releated bug #3456. I'll add a fix for that. It would help fixing new issue.

@gi0e5b06
Copy link

@PhysSong Also double-click in the file browser. The second click happens outside the previewing and so add the controller. I fixed that too.

@PhysSong
Copy link
Member Author

PhysSong commented Oct 25, 2017

The second commit fixes #3456.
Note: lock***()-style functions should be replaced with safer QMutexLocker later anywhere available.

Edit: done by bdf4884.

@PhysSong PhysSong changed the title Fix crash when closing while previewing preset Fix crashes and deadlocks with previewing preset Oct 25, 2017
@zonkmachine
Copy link
Contributor

The second commit fixes #3456.

Both bugs and their fixes confirmed.

@PhysSong
Copy link
Member Author

This PR seems to work good. However, I will add some commits to remove potential chances to generate errors because I've changed some lock-related parts. I think using atomic pointers can be a solution.

@PhysSong
Copy link
Member Author

Note: lock***()-style functions should be replaced with safer QMutexLocker later anywhere available.

I will add some commits to remove potential chances to generate errors because I've changed some lock-related parts.

Done by bdf4884.

@zonkmachine
Copy link
Contributor

I've retested this PR and it still works like a charm. I also retested the bug in question and it seem the crash on exit doesn't happen if the project is playing, only when previewing and the song is stopped.

@PhysSong
Copy link
Member Author

Merge?

@zonkmachine
Copy link
Contributor

Totally...

@PhysSong
Copy link
Member Author

Okay. I'll merge it soon. 😄

@PhysSong PhysSong merged commit 60e9b2f into LMMS:stable-1.2 Oct 29, 2017
@PhysSong PhysSong deleted the previewcrash branch October 29, 2017 11:26
sdasda7777 pushed a commit to sdasda7777/lmms that referenced this pull request Jun 28, 2022
* Fix crash when closing while previewing preset * Fix deadlock on previewing presets while playing arpeggio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants