Skip to content

[DEV BUG] Crash when done=1 is set in preset causing the SpriteManager to destroy the sprite while still iterating over the sprite list in Draw() #912

@kholbrook1303

Description

@kholbrook1303

Please confirm the following points:

  • This report is NOT about the Android apps in the Play Store
  • I have searched the project page to check if the issue was already reported

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.

Metadata

Metadata

Assignees

Labels

bugThe issue is (potentially) a bug.

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions