[ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

MusE is a DAW for Linux with both MIDI and Audio editing. https://muse-sequencer.github.io

Moderators: MattKingUSA, khz, spamatica

Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

[ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Hi. Just wanted to post a separate message about this.
Fixed in github master now.

For a long time we have had crashes when simply loading another song or selecting File > New or File > Close.
It usually happens when various editor windows are already open.

I have now tested re-loading various simple and complicated songs over and over and over again, with no crashes.
You should be able to do the same now.
Please let me know if any trouble.

[ Tech talk: ]
Each of us has tried various fixes over the years, but no one got to the heart of the matter.
There is a section of code that wants to a) close all open windows and then b) clear the song of all tracks, parts, markers, tempos etc.
Some of the windows are marked as 'delete on close' meaning they delete themselves after closing.
And there's the trouble. Calling close() on such windows does NOT immediately delete at the end, it calls deleteLater(),
to be deleted at a later time.
This meant that the various windows were still alive when we next attempted to clear the song of all tracks, parts etc.
Also various connections to the windows such as our GUI heartbeat timer, our songChanged, and our configChanged signals
were still alive at the time of clearing the song.
So the still-alive windows were then attempting to use these now-deleted tracks, parts etc.
Crash!
So it was imperative that we wait until the windows have really been deleted before moving on to clearing the song.
Simply calling processEvents() in a loop did nothing to help.
It turns out that we must call QCoreApplication::sendPostedEvents() instead.
From help on processEvents():

In the event that you are running a local loop which calls this function continuously, without an event loop,
the DeferredDelete events will not be processed. This can affect the behaviour of widgets, e.g. QToolTip,
that rely on DeferredDelete events to function properly. An alternative would be to call sendPostedEvents()
from within that local loop.

OK. Except it didn't work. Simply calling sendPostedEvents() with default arguments should have worked but it didn't.
So after some searching, thank the coding Gods I found this old post:
https://lists.qt-project.org/pipermail/ ... 22513.html
It turns out there's some kind of slight Qt bug where specifically for DeferredDelete events,
the poster had to specifically call "sendPostedEvents(0, QEvent::DeferredDelete)".

Presto! Problem solved!
All the windows deleted and then I could move on to clearing the song safely.

This took me the whole weekend to solve and I just found the solution and fixed it this Monday morning.
I was about ready to give up and try some really exotic stuff like running another QThread etc.
which likely would not have worked.

See ya!

Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

I got an immediate reply from Qt:

Not a bug. Deferred deletions depend on the loop nesting level and calling processEvents or sendPostedEvents
directly will not cause those you've just posted to get processed. You need return.

Hm. Well, it seems to work now.

User avatar
oscillator
Established Member
Posts: 1127
Joined: Sat Jan 17, 2015 6:07 pm
Location: SWEDEN
Has thanked: 725 times
Been thanked: 298 times
Contact:

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by oscillator »

I am going to try this, as this has happened to me a few times. A not so annoying crash, as everything is saved before etc.

But. I must really thank you @Tim E. Real for all your latest bug-squashing!!! I find MusE very stable now and it means a lot.

The only thing I could wish for now for MusE is VST3 and CLAP support. :D Is that something we could crowdfound for you to create, @Tim E. Real?

MusE DAW running on Debian 11 Testing/XFCE4.
https://oscillator.se/musik

Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Heh, the more long-winded my posts are, the more it's a clue that I might be wrong :roll:
I probably should obey what the Qt response said.
I'm looking at reverting to a previous method I had tried, to be safe. (Waiting for the 'destroyed' signals instead.)
It's just that to do that, will make it annoyingly complicated ...

I cannot quite attempt to start big tasks like VST3 yet at the moment, at least by me.
I am trying to finish a couple of very important things before moving on.
I need some more time to clear the backlog of stuff I was working on.

spamatica
Established Member
Posts: 583
Joined: Mon Feb 08, 2010 10:38 am
Has thanked: 87 times
Been thanked: 101 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by spamatica »

Tim E. Real wrote: Tue May 09, 2023 2:15 pm

I'm looking at reverting to a previous method I had tried, to be safe. (Waiting for the 'destroyed' signals instead.)
It's just that to do that, will make it annoyingly complicated ...

I dunno how unorthodox the solution you added is. Seems it's an improvement at least, in which case it seems to me it is just a question of priorities.. Possibly it's better spending the energy on some other improvement and leave this for now.

MusE DAW
Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Hi all. Now in github master:

I have re-written the song clearing/loading code to comply with the bug report instructions.
It is behaving well.
It is a radically different way of handling these things, so in case there may be some things that were overlooked or neglected,
please let me know if any trouble.

In addition, I discovered some pre-existing long-time crashes.
Simply start MusE, then press Ctrl-N (File New) more than once rapidly (either by accident or on purpose).
Crash. Because it is already in the middle of clearing/loading when the second/third etc. requests come in, too soon.
Similar for Ctrl-O (File Open), Import Midi, etc.
A mechanism was installed to ignore such multiple requests until fully done clearing/loading.
Note that it is possible that some other menu items in MusE still might cause this type of crash.
We'll get them one at a time. For now these fixes should stop these specific crashes.

User avatar
Impostor
Established Member
Posts: 1392
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 366 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Impostor »

Tim E. Real wrote: Sat May 13, 2023 6:44 pm

Hi all. Now in github master:

Funny story:
I installed the latest master, ran muse, opened new project, crash.
But it turns out that it's related to fluida.lv2 (muse opened my last project on starting up, involving fluida, and from there I opened a new project). Some weird stuff going on with that plugin. Apparently something about libinstpatch not working how it should.

MusE also crashes if I load fluida.lv2 as the first lv2 plugin in a new project. If I load a couple of other lv2's first, then fluida loads fine...but I don't trust that plugin anymore to survive my closing and reopening projects. I'll just keep using MusE's own soundfont player.

Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Built Fluida from master source. Seems stable here.
Did you build from source?

Feel free to post console output and/or a debug trace.

User avatar
Impostor
Established Member
Posts: 1392
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 366 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Impostor »

Tim E. Real wrote: Sat May 13, 2023 11:40 pm

Built Fluida from master source. Seems stable here.
Did you build from source?

Feel free to post console output and/or a debug trace.

Yes, I've built fluida from git.
Steps to reproduce:

  1. delete MusE/projects file (just to ensure the problem is due to the next steps)
  2. run MusE (opening to a completely empty project. No template)
  3. Add fluida synth track
  4. Click on new project (again: no template)
  5. Add fluida synth track OR add fluidsynth (MusE's own) synth track

Now MusE hangs indefinitely, and console output is

Code: Select all

Config File </home/orbit/.config/MusE/MusE/MusE-seq.cfg>

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchSplitsType'

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.750: g_param_spec_enum: assertion 'G_TYPE_IS_ENUM (enum_type)' failed

** (muse4:4702): CRITICAL **: 11:49:52.750: ipatch_type_install_property: assertion 'G_IS_PARAM_SPEC(prop_spec)' failed

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.750: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchSF2GenType'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot retrieve class for invalid (unclassed) type '<invalid>'

** (muse4:4702): CRITICAL **: 11:49:52.750: file /build/libinstpatch-i701yY/libinstpatch-1.1.2/libinstpatch/IpatchSF2Gen.c: line 148 (_ipatch_sf2_gen_init): assertion `enum_class != NULL' failed.

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchSample'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchItem'

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.750: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchSF2GenItem'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchItem'

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.750: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchSF2ModItem'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.750: cannot register existing type 'IpatchItem'

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.750: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot register existing type 'IpatchSF2VoiceCache'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot retrieve class for invalid (unclassed) type '<invalid>'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot register existing type 'IpatchItem'

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.751: g_type_register_static: assertion 'parent_type > 0' failed

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.751: g_type_register_static: assertion 'parent_type > 0' failed

(muse4:4702): GLib-CRITICAL **: 11:49:52.751: g_once_init_leave: assertion 'result != 0' failed

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot retrieve class for invalid (unclassed) type '<invalid>'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot register existing type 'IpatchItem'

(muse4:4702): GLib-GObject-CRITICAL **: 11:49:52.751: g_type_register_static: assertion 'parent_type > 0' failed

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot retrieve class for invalid (unclassed) type '<invalid>'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot register existing type 'IpatchConverter'

(muse4:4702): GLib-GObject-WARNING **: 11:49:52.751: cannot retrieve class for invalid (unclassed) type '<invalid>'

Now, if I do the following though, this crash does not occur:

  1. delete MusE/projects file
  2. run MusE
  3. Add fluida synth track AND add a fluidsynth (MusE's own) track
  4. Click on new project
  5. Add fluida synth track
Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Verified!
Same hang, same errors.

Thanks very much for the test.
Will try to investigate. Quite busy at the moment... Hang in there... Could be delayed.

In the meantime, if you have time, file a bug report and mention the test and that it was verified by me.

Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Although, it does initially appear to be a problem with Fluida.
It hangs at this line in LV2SynthIF::init() in MusE:

Code: Select all

    _state->handle = _handle = lilv_plugin_instantiate(_synth->_handle, (double)MusEGlobal::sampleRate, _state->_ppifeatures);

So we are handing off execution to that lilv_plugin_instantiate() LV2 function and it's hanging inside there.
Also, our own fluidsynth uses libinstpatch without trouble, so that's a clue...

User avatar
Impostor
Established Member
Posts: 1392
Joined: Wed Aug 17, 2022 1:55 pm
Has thanked: 148 times
Been thanked: 366 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Impostor »

Tim E. Real wrote: Sun May 14, 2023 4:08 pm

Verified!
Same hang, same errors.

Thanks very much for the test.
Will try to investigate. Quite busy at the moment... Hang in there... Could be delayed.

In the meantime, if you have time, file a bug report and mention the test and that it was verified by me.

On the fluida git issues page, there's already a report on libinstpatch misbehaving. I think it's likely the same issue.
Further link:
https://github.com/swami/libinstpatch/issues/72

Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

OK Thanks.
Yeah, I tried to crash it in QTractor, but no crash so far...

Maybe we'll put this one aside for now and monitor that bug report for changes.
I have followed all the threads there, looks like it's an ongoing issue...

tramp
Established Member
Posts: 2348
Joined: Mon Jul 01, 2013 8:13 am
Has thanked: 9 times
Been thanked: 468 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by tramp »

Hi, solution for this issue is easy, but could only be done by the host.
https://github.com/brummer10/Fluida.lv2 ... 1547152732

On the road again.
Tim E. Real
Established Member
Posts: 669
Joined: Sat Sep 15, 2012 12:36 am
Has thanked: 40 times
Been thanked: 110 times

Re: [ Fixed ] Ancient crashes when loading another song or file > 'new' or 'close'

Post by Tim E. Real »

Thanks, I posted a note there, I was curious about how MusE does things and how it relates.

Post Reply