MuseScore
MuseScore copied to clipboard
[MU4 Issue] Crash when selecting theme (Linux, in some conditions)
Describe the bug MuseScore 4.0.0 alpha 2 crash when selecting theme
To Reproduce Steps to reproduce the behavior:
- Start MuseScore 4.0.0 alpha 2.
- When asked for the them, click on "Dark"
- Crash
Expected behavior No crash
Screenshots If applicable, add screenshots to help explain your problem.
Platform information
- OS: Linux, Flatpak. Before you send me to the maintainer of the package, I'll go recursive and tell you up from I am. As os this moment this is still a local build.
Additional context
tl;dr, calling front()
on an empty container is INVALID (this is not specific to std::u16string
). The crash is actually an assert, and assert are enabled by default when building flatpaks.
CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer
I applied that patch and it works.
diff --git a/src/framework/global/types/string.cpp b/src/framework/global/types/string.cpp
index e255f17a21..06b640241d 100644
--- a/src/framework/global/types/string.cpp
+++ b/src/framework/global/types/string.cpp
@@ -477,6 +477,9 @@ String String::fromQString(const QString& str)
QString String::toQString() const
{
+ if (empty()) {
+ return QString();
+ }
const char16_t* u = &constStr().front();
static_assert(sizeof(QChar) == sizeof(char16_t));
return QString(reinterpret_cast<const QChar*>(u), static_cast<int>(size()));
@hfiguiere Strange.. I can't reproduce it on my side..
Does it occur if to Revert to factory settings and on the next MuseScore start choose Dark theme again? (without applying you fix)
It was the first start ever of MuseScore 4. So, yeah.
Did you try with a build that has -D_GLIBCXX_ASSERTIONS
(CXXFLAGS
) ? It might bot reproducible with older libstdc++, (like a 5 year old Ubuntu you seem to favour).
Did you try with a build that has -D_GLIBCXX_ASSERTIONS (CXXFLAGS) ? It might bot reproducible with older libstdc++, (like a 5 year old Ubuntu you seem to favour).
Nope.. I'm not a developer, just a QA tester)
OK, let's leave that issue open since it might occur on some Linux versions
The bug this address is :
https://en.cppreference.com/w/cpp/string/basic_string/front
Returns reference to the first character in the string. The behavior is undefined if empty() == true.
Newer libstdc++ with assertion enabled do assert on the condition.
Can't reproduce. Ubuntu 12
@hfiguiere Could you please check #12799?
(For the record: this won't be reproducible in any build that is created on GitHub, because we always build in release mode, without assertions. On macOS, the crash also doesn't occur in debug mode, but that is likely because macOS uses a different version of the standard library than Linux. But fact is, that we are invoking undefined behaviour, which is just bad and should be fixed.)