Bug 420718

Summary: juk segfaut on every startup
Product: [Applications] juk Reporter: Markus <m4rkusxxl>
Component: generalAssignee: Scott Wheeler <wheeler>
Status: RESOLVED FIXED    
Severity: normal CC: mpyne
Priority: NOR Keywords: regression
Version: 20.04   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 20.04.1
Attachments: Backtrace from debug build
use back_inserter with fill_n on empty list

Description Markus 2020-04-28 18:30:04 UTC
SUMMARY
Just start juk, it will fail with segfault.

STEPS TO REPRODUCE
1. Start juk.

OBSERVED RESULT
Segfault.

EXPECTED RESULT
It should work.

SOFTWARE/OS VERSIONS
Linux: 5.6.7
KDE Plasma Version: 5.18.4.1
KDE Frameworks Version: 5.69.0
KDE Application Version: 20.04.0
Qt Version: 5.14.1
Comment 1 Markus 2020-04-28 18:31:10 UTC
Created attachment 127957 [details]
Backtrace from debug build
Comment 2 Markus 2020-04-30 05:00:55 UTC
Downgrade just juk to 19.12.3 makes it work again.
Comment 3 Markus 2020-04-30 19:26:31 UTC
QStringList allColHeaders;
allColHeaders.reserve(numColumnsToReserve + standardColHeaders.size());
std::fill_n(allColHeaders.begin(), numColumnsToReserve, i18n("JuK"));

Introduced here:
https://cgit.kde.org/juk.git/commit/playlist.cpp?id=a800c1b3ffeb1672cf889e707baf2b181d7fc8f1
https://phabricator.kde.org/R344:a800c1b3ffeb1672cf889e707baf2b181d7fc8f1
Comment 4 Markus 2020-05-01 08:44:24 UTC
Created attachment 128055 [details]
use back_inserter with fill_n on empty list

fill_n is more a overwrite than an insert.
Comment 5 Michael Pyne 2020-05-10 15:58:38 UTC
Git commit e843f457d5656d778396d8045289117443b70975 by Michael Pyne.
Committed on 10/05/2020 at 15:52.
Pushed by mpyne into branch 'master'.

playlist: Fix crasher with playlists using reserved columns.

I introduced this bug in commit a800c1b3ffeb trying to fix a different
memory mis-using bug. Sigh.

In this case playlists that reserve additional columns would get a valid
memory assignment but would be copied into the memory block incorrectly.
This needed a back_inserter as well.

Thanks to Markus for pointing out the regression, then opening a bug,
then leaving a comment to point out both of these, and then drafting a
patch that fixes the bug.

I can confirm it works in my testing, it also seems to address a bug
relating to playback stopping abrupting at the end of a track instead of
skipping to the next track, but who knows at this point.
FIXED-IN:20.04.1

M  +1    -1    playlist.cpp

https://invent.kde.org/kde/juk/commit/e843f457d5656d778396d8045289117443b70975