musescore / musescore/MuseScore

Crash or huge memory leak on opening score with Staff Type Change (added twice)

Open
#25,145 5 comments 0 reactions 1 assignee View on GitHub

Nobody has claimed this yet.

crash P2
Dominant language
C++
Stars
15.1k
Forks
3.3k
Avg merge
2d 2h
Merged PRs (30d)
91

Description

Issue type

Crash or freeze

Description with steps to reproduce

This issue is based on a report from musescore.org (problematic file fallingtidesrise-percussion.mscz )
Normally when user adds Staff Type Change, Musescore writes it to the file like this:

<StaffTypeChange>
  <StaffType group="percussion">
    <name>perc1Line</name>
    <keysig>0</keysig>
    </StaffType>
</StaffTypeChange>

However in some cases a "zeroed" record (or many records) may be added which looks like this:

<StaffTypeChange>
  <StaffType group="">
     <lines>0</lines>
     <lineDistance>0</lineDistance>
     <mag>0</mag>
     <stepOffset>132474896</stepOffset>
     <slashStyle>242</slashStyle>
     <stemless>242</stemless>
     <timesig>0</timesig>
     <color r="0" g="0" b="0" a="0"/>
     <durations>0</durations>
     <durationFontName>MuseScore Tab Modern</durationFontName>
     <durationFontSize>0</durationFontSize>
    ...
  </StaffType>
</StaffTypeChange>

When saved, the project cannot be opened again - Musescore crashes/hangs/memory leaks.
If <mag>0</mag> removed, the project can be opened again.

Tested with Musescore 4.4.2 and 4.5.0 master.

The only way I could reproduce this state from scratch:

  1. add two StaffTypeChange elements to the same measure in parts.
  2. Close/reopen score
  3. Remove one StaffTypeChange element.
  4. If remaining StaffTypeChange element looks empty (without lines inside), save score
  5. Close/reopen project - > Musescore freezes/crashes + memory leaks.
    It may take a few tries to reproduce the situation. Opening the properties panel for the StaffTypeChange element may help.
    Attaching a template to reproduce from scratch
    StaffTypeChangeIssue5_gh.mscz.zip
Supporting files, videos and screenshots

https://github.com/user-attachments/assets/62b77cc2-03da-4b3e-aae6-d56142d3338e

What is the latest version of MuseScore Studio where this issue is present?

MuseScore Studio version (64-bit): 4.5.0-242870307, revision: github-musescore-musescore-0c45d97

Regression

The crash also occurs in 3.6.2

Operating system

windows 10, but macs are affected too

Additional context

Another report https://musescore.org/en/node/378646 with scores:
La Morte (version 2)_0.zip
La Morte_0.zip

Checklist
  • This report follows the guidelines for reporting bugs and issues
  • I have verified that this issue has not been logged before, by searching the issue tracker for similar issues
  • I have attached all requested files and information to this report
  • I have attempted to identify the root problem as concisely as possible, and have used minimal reproducible examples where possible

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.