Crash when adding a note on a track with Muse Sounds
Description:
When a note is added on a track with Muse Sounds as playback sounds, the application crashes because of a failing assert (Fatal (internal) error in ../opus-1.5.1/src/opus_decoder.c, line 108: assertion failed: st->stream_channels == 1 || st->stream_channels == 2
) when opus-1.5.1-1 is installed.
The assert fails because of two different versions of libopus being linked into the same object (mscore executable). The sys lib /usr/lib/libopus.so is loaded dynamically by libMuseSamplerCore.so which is again loaded dynamically into the mscore object, and at the same time, thirdparty/opus is also statically linked into the mscore object through thirdparty/opusenc. Because of differing versions and different compile options being used, the OpusDecoder struct has a different memory layout. Therefore the wrong memory regions is accessed and the assert fails. To make it work the version of opus in the thirdparty/opus directory version has to match the system version and the compile options have to match the ones used to build the system libopus.so. I've provided more detail on the issue on the upstream issue in these comments:
- https://github.com/musescore/MuseScore/issues/21838#issuecomment-2040619807
- https://github.com/musescore/MuseScore/issues/21838#issuecomment-2032575700
Proposed fix options
To fix the issue I propose either:
- changing the PKGBUIlD to first delete the thirdparty/opus dir, then download the libopus source code containing a CMakeLists.txt e.g. the git repo that matches your system libopus.so into thirdparty/opus (in Arch's case it's tag
v1.5.1
of opus). Then run theautogen.sh
script in it and finally, configure CMake with the compile options matching libopus.so (in Arch's case at least these:-DOPUS_DRED=ON -DOPUS_DEEP_PLC=ON -DOPUS_OSCE=ON
) and build it. Then it should work and it isn't that difficult to update the PKGBUILD to do this. I don't think it's the best way to solve it like this because each time a new opus version is released you'd also need to update the musescore package to avoid such library conflicts.
or (which I think is a way more sustainable option)...
- add opus as a dependency and add the CMake flag MUE_COMPILE_USE_SYSTEM_OPUS I propose in this PR if it gets merged. Then, there would be just one version of libopus linked (just the /usr/lib/libopus.so system library) which would fix the problem hopefully for a long time (libopus releases are API and ABI compatible (according to the maintainer), therefore this should work in the long-term).
Notes:
- the thirdparty files/dirs are partially (opus and opusenc and others) in a different directory in the newer master version
Additional info:
- package version(s): musescore-4.2.1-1, opus-1.5.1-1
- config and/or log files: crash.log
- link to upstream bug report, if any: https://github.com/musescore/MuseScore/issues/21838
Steps to reproduce:
- Have a Muse Sound (e.g. piano Muse sounds) and opus-1.5.1-1 installed
- Start musescore-4.2.1-1
- Add a new track (make sure that in the Mixer View a Muse sound is selected for the track)
- Add a note to the track
- MuseScore will crash with the attached crash log