Lv2: Crash loading sfizz due to missing scale points
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 1.3k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 7
Description
### System Information
Irrelevant
### LMMS Version(s)
All
### Most Recent Working Version
_No response_
### Bug Summary
Sfizz has scale points with duplicate labels:
```
] , [
a lv2:InputPort, lv2:ControlPort ;
lv2:index 5 ;
lv2:symbol "num_voices" ;
lv2:name "Polyphony",
"Polyphonie"@fr ,
"Polifonia"@it ;
pg:group ;
lv2:portProperty pprop:notAutomatic ;
lv2:portProperty pprop:expensive ;
lv2:portProperty lv2:integer ;
lv2:portProperty lv2:enumeration ;
lv2:default 64 ;
lv2:minimum 8 ;
lv2:maximum 256 ;
lv2:scalePoint [ rdfs:label "8 voices",
"8 voix"@fr ,
"8 Voci"@it;
rdf:value 8
] ;
...
```
So, loading it lets lilv fail to load the scale points:
```
lilv_world_get_unique(): warning: Subject <173b15> has multiple properties
lilv_plugin_get_unique_internal(): error: No value found for (173b15 http://www.w3.org/2000/01/rdf-schema#label ...) property
```
This later leads to a crash in `Lv2Proc::copyModelsFromCore` (called by `createPorts`) in the code line `m_res = (*m_scalePointMap)[static_cast(m.value())];`, where `m.value()` is still 0, but the `scalePointMap` is entirely empty. For more info, see backtrace in the logs.
### Expected Behaviour
Since the port has the `enumeration` label, it [should](https://lv2plug.in/ns/lv2core#enumeration) be displayed with a ComboBox which uses the ScalePoints. Since these are not available though, we have the following options:
1. enumeration ports without proper scalePoints are displayed as normal knobs instead. The [Lv2 core specs](https://lv2plug.in/ns/lv2core#enumeration) say "that the plugin MUST [still] operate reasonably" in that case. However, the danger is that in practice, plugins are not that safe against non-scalePoint maps.
2. Refuse to load plugins where loading the scalePoints fails. Especially, such plugins might be added to the Lv2 blocklist.
### Steps To Reproduce
Open LMMS, load sfizz as Lv2 plugin.
### Logs
Click to expand
#4 0x00005555558fa7db in std::vector >::operator[] (this=0x7fffa0011280, __n=0) at /usr/include/c++/16.1.1/bits/stl_vector.h:1272
#5 0x0000555555920c08 in FloatFromModelVisitor::visit (this=0x7fffa58ed610, m=...) at src/core/lv2/Lv2Proc.cpp:242
#6 0x00005555557f56eb in lmms::ComboBoxModel::accept (this=0x7fffa00112b0, v=...) at include/ComboBoxModel.h:41
#7 0x0000555555920d0b in Copy::visit (this=0x7fffa58ed690, ctrl=...) at src/core/lv2/Lv2Proc.cpp:251
#8 0x000055555592f6d7 in lmms::Lv2Ports::VisitablePort::accept (this=0x7fffa0011240, v=...) at include/Lv2Ports.h:150
#9 0x0000555555920ff8 in lmms::Lv2Proc::copyModelsFromCore (this=0x7fffa0001730) at src/core/lv2/Lv2Proc.cpp:273
#10 0x00005555559237a9 in lmms::Lv2Proc::createPorts (this=0x7fffa0001730) at src/core/lv2/Lv2Proc.cpp:805
#11 0x0000555555920854 in lmms::Lv2Proc::Lv2Proc (this=0x7fffa0001730, plugin=0x555556751210, parent=0x7fffa00012f0) at src/core/lv2/Lv2Proc.cpp:200
### Screenshots / Minimum Reproducible Project
_No response_
### Please search the issue tracker for existing bug reports before submitting your own.
- [x] I have searched all existing issues and confirmed that this is not a duplicate.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the sfizz loading crash, then read src/core/lv2/Lv2Proc.cpp around copyModelsFromCore, createPorts, and the reported scale-point access, along with include/Lv2Ports.h. Determine whether malformed enumeration scale points should fall back to knobs or prevent loading, and verify that sfizz no longer crashes and follows the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100