Bug 476651 - KPA crashes when sorting item in thumbnail view by date/time
Summary: KPA crashes when sorting item in thumbnail view by date/time
Status: RESOLVED FIXED
Alias: None
Product: kphotoalbum
Classification: Applications
Component: Thumbnail Viewer (show other bugs)
Version: GIT master
Platform: Compiled Sources Linux
: NOR crash
Target Milestone: ---
Assignee: KPhotoAlbum Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-06 23:10 UTC by Andreas Schleth
Modified: 2023-11-07 23:20 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
crash report from drkonqui (4.93 KB, text/vnd.kde.kcrash-report)
2023-11-06 23:10 UTC, Andreas Schleth
Details
tar file with two kphotoalbumrc files (120.00 KB, application/x-tar)
2023-11-07 17:51 UTC, Andreas Schleth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schleth 2023-11-06 23:10:58 UTC
Created attachment 162916 [details]
crash report from drkonqui

SUMMARY
Crash when sorting items by date/time in thumbnail view. Reproducible with the same dataset and with another database and different data. Does not crash when the items are already sorted.

STEPS TO REPRODUCE
1. Have some out of order images/videos in the thumbnail view
2. Select these items
3. Select from the menu: "View" ... "Sort Selected by Date & Time"

OBSERVED RESULT
Crash

EXPECTED RESULT
Display items in sorted order. No crash.

SOFTWARE/OS VERSIONS
openSuse Leap 15.5
KPA git master v5.11.0-171-g314e3ca7
KDE Frameworks 5.103.0
Qt 5.15.8
Plasma 5.27.4

ADDITIONAL INFORMATION
A) The bug must be introduced quite recently as I did a lot of sorting in the last few days and had quite a few recent versions installed
B) The terminal says:
ASSERT failure in QList::insert: "The specified iterator argument 'before' is invalid", file /usr/include/qt5/QtCore/qlist.h, line 541
KCrash: Application 'kphotoalbum' crashing...
C) see attachment
Comment 1 Andreas Schleth 2023-11-06 23:11:50 UTC
see also: https://bugs.kde.org/show_bug.cgi?id=476561
Comment 2 Andreas Schleth 2023-11-06 23:20:09 UTC
Easier way to reproduce:
1. kphotoalbum --demo
2. thumbnail view
3. crtl-a
4. sort
5. crash
Comment 3 Andreas Schleth 2023-11-06 23:29:15 UTC
This is strange: 
I tried a git bisect going back until 5.9.something from January 2023 and it still crashes while sorting the demo database.
???
Comment 4 Andreas Schleth 2023-11-07 17:50:30 UTC
I cannot reproduce the crash on a different machine ... m-(

On a second PC with slightly older/smaller hardware but the same OS/patchlevel the crash never happens. 
I am building with the exact same build script from the very same folder (on NFS) on both systems. On the other PC the crash does not happen. On this one it is reproducible.
I checked/compared all the files mentioned in the kcrash file - they differ only in access time but otherwise they are the same bit for bit.
The .gitconfig files are the same on both machines and before each build I clean out the build folder.

But ... but: the .config/kphotoalbumrc files differ !!!
With the file on my machine KPA crashes, with the file from the other it does not crash.
I can exchange the two *rc files and the crash follows the defective one.

Now, what on earth could cause the config file to crash the application?
Comment 5 Andreas Schleth 2023-11-07 17:51:45 UTC
Created attachment 162933 [details]
tar file with two kphotoalbumrc files

The file kphotoalbumrc5 causes the crash when sorting, the other one is OK
Comment 6 Andreas Schleth 2023-11-07 18:49:10 UTC
OK ... (sigh!) ... I edited the offending rc-file line by line and this is the offending line in the section [Thumbnails]:

[Thumbnails]
...
showNewestThumbnailFirst=true

When I remove only this line, sorting does not crash anymore.
Adding this line should trigger the crash. 

Completely removing the rc-file and starting from scratch solves this problem as well but then you have to re-do all your settings.

My verdict: settings in the rc-file should not crash the application.
Comment 7 Johannes Zarl-Zierl 2023-11-07 22:39:45 UTC
Git commit eb3e2fe95ab48f984d79125e36562c5955ceae7c by Johannes Zarl-Zierl.
Committed on 07/11/2023 at 23:29.
Pushed by johanneszarl into branch 'master'.

Fix crash when sorting selected images newest first

If the display order is newest first, selecting all images and sorting
the selected images resulted in a out of bounds iterator.

M  +2    -1    DB/ImageInfoList.cpp

https://invent.kde.org/graphics/kphotoalbum/-/commit/eb3e2fe95ab48f984d79125e36562c5955ceae7c
Comment 8 Johannes Zarl-Zierl 2023-11-07 22:45:06 UTC
Thanks for the detailed report.

For the record: The steps to reproduce this bug using the GUI only:
1. Open KPhotoAlbum
2. Select View | Show Newest First
3. Go To Thumbnail View
4. Select all images
5. Select View | Sort selected by Date & Time

Apparently nobody ever tried sorting the images while the display order was newest first...
Comment 9 Andreas Schleth 2023-11-07 23:20:36 UTC
Hi Johannes,
with the latest update things work for me independent of sort order. So, check, problem solved!
I must have switched the sort order inadvertently.
Thanks! Andreas