Please confirm the following points:
Affected Project
libprojectM (including the playlist library)
Affected Version
4.2
Operating Systems and Architectures
All
Build Tools
Build Tool: CMake
Additional Project, OS and Toolset Details
Using on Windows 11 and also in Raspberry Pi OS Bookworm
Type of Defect
Crash (unhandled exceptions, segmentation faults)
Log Output
Segmentation fault:
0x00007fffd7efefe0 in libprojectM::UserSprites::SpriteManager::Draw(libprojectM::Audio::FrameAudioData const&, libprojectM::Renderer::RenderContext const&, unsigned int, std::vector<std::reference_wrapper<std::unique_ptr<libprojectM::Preset, std::default_delete<libprojectM::Preset> > const>, std::allocator<std::reference_wrapper<std::unique_ptr<libprojectM::Preset, std::default_delete<libprojectM::Preset> > const> > >) () from /usr/local/lib/libprojectM-4.so.4
Describe the Issue
When setting 'done' in a sprite config, a seg fault is exhibited after loading the sprite and meeting the 'done' condition. This is due to 'm_sprites' being modified during iteration.
Simple sprite config to reproduce:
[img00]
img=logo
init_1=blendmode = 4;
code_1=sx = 0.9 + 0.1 * (bass - 1.0);
code_2=sy = 0.9 + 0.1 * (bass - 1.0);
code_3=done=above(frame,120);
code_4=burn=1;
I resolved this by creating a toDestroy vector to destroy sprites after iterating over m_sprites.