Closed jieweix closed 2 years ago
I can't reproduce it on my system (DeaDBeeF 1.9.1). With resuming a paused track, do you mean simply hitting pause and then play again, or pausing a track, quitting DeaDBeeF (with session restore enabled) and then start playing where it was paused?
@cboxdoerfer It occurs on latest deadbeef master with the latest musical spectrum widget (binary from the plugins page). FFT size set to 16K. For me it crashes instantly when I press play. Maybe you need to press play a few times.
I mean simply hitting pause and then play again. Actually it occurs on both 1.9.1 (installed by apt
) and the latest master for me, exactly same situation
@Oleksiy-Yakovenko, I already tried spamming the play/pause button, but no crash happend. I'll try the nightly builds and spectrum binary from the plugins page next.
I suppose you're both playing usual audio files, like no huge number of channels or something like that?
Yes, 2-channel, 16-bit, 44.1-kHz FLAC files.
Also no crash with DeaDBeeF Nightly build and the plugin from the plugin page. Were the spectrum plugin settings (except for the increased FFT size) modified in any way?
I disabled Peaks and set Style to Solid instead of Musical.
Also no crash with an Ubuntu 22.04 VM. Is the musical spectrum the only third party plugin installed?
I also have Discord Rich Presence Plugin installed.
Also no crash with DeaDBeeF Nightly build and the plugin from the plugin page. Were the spectrum plugin settings (except for the increased FFT size) modified in any way?
I deleted the ~/.config/deadbeef folder before reproducing this bug. Maybe I switched between ALSA and Pulse plugins, can't remember.
@jieweix, seems unlikely that this plugin could have an effect on this issue. Hm... I'm kind of out of ideas now, in terms of managing to reproduce it. Would you be willing to build the spectrum plugin from source and add some debug output to it, so I can get a better idea what might be going wrong?
@cboxdoerfer did you set FFT size of the musical spectrum plugin to 16K? strange if it didn't crash for me, it started crashing for me immediately.
@cboxdoerfer did you set FFT size of the musical spectrum plugin to 16K? strange if it didn't crash for me, it started crashing for me immediately.
Yes, I tried 16k and 32k.
Hm, so my first guess is that this might be a race condition. It's been quite a while since I've worked on this, but I'm kind of surprised why my vis_waveform_listen
callback for the spectrum (https://github.com/cboxdoerfer/ddb_musical_spectrum/blob/master/spectrum.c#L123) has no mutex locking — it seems it should have.
@Oleksiy-Yakovenko reminded me of different output plugins, namely PulseAudio and ALSA. I switched from ALSA to PulseAudio in preferences and the problem seemed to never occur again, and even the scratching sound and break disappeared.
@jieweix yes indeed, with the ALSA plugin I can reproduce it in a VM, but not on my main system (might be because the ALSA backend is provided by pipewire there).
@Oleksiy-Yakovenko @jieweix I think I've found the bug. It's seems to be that the plugin is fine and there's an issue within DeaDBeeF — I can trigger the same bug with the built-in scope visualizer.
The problem seems to be that under certain circumstances data
in ddb_audio_data_t
, which gets passed to the visualizers (https://github.com/DeaDBeeF-Player/deadbeef/blob/master/viz.c#L192), is too small for the reported nframes
(or vice versa, nframes
should be smaller to not exceed the size of data
).
Here's the state of the parameters at the time of a crash in viz_process
: data_size: 65536, fft_size: 4096, wave_size/nframes: 16383
So the scope and spectrum plugins see that there are supposedly 16383
frames and consequently think that data
must at least be 16383 * num_channels * sizeof(float)
large, i.e. 131064 bytes with 2 channels, when in fact it's only 65536
bytes. Hence the segfault when the plugins use memcpy
on data
: https://github.com/DeaDBeeF-Player/deadbeef/blob/master/scope/scope.c#L81
@cboxdoerfer thanks for digging into this. What circumstances do I need to create in order to trigger the bug?
@Oleksiy-Yakovenko Basically the same I had to do to reproduce the crash with the spectrum plugin: have the scope/oscilloscope in the layout, use the ALSA output plugin, use a VM and hit play/pause a few times. Since you were able to trigger the crash with the musical spectrum plugin more easily on your PC, you probably just have to replace the spectrum with the scope and hit play/pause.
The scope visualization also sometimes produces lots of visual noise on play/pause in the cases it doesn't crash:
That maybe comes from copying and visualizing those random memory regions outside of data
.
Edit: I also have more luck to trigger the segfault right after starting DeaDBeeF.
ok.. this bug has been reported to me a few months ago, but I was never able to reproduce it. anyway, I guess if I can trigger it with musical spectrum -- I'll be able to figure out what's going onw.
I'll reopen the issue in deadbeef tracker, this one can be closed.
Ok, thx.
Here's the backtrace @Oleksiy-Yakovenko got: (https://github.com/DeaDBeeF-Player/deadbeef/issues/2845)
and here's my log:
When FFT size is configured 8192 samples or below, it doesn't crash but switches to the next track (if there's a next track; if there's only one track it just continues playing) after resuming a paused track (not always).