Bug 476862

Summary: KPhotoAlbum git master crashes when range selected in Datebar extends out of main screen
Product: [Applications] kphotoalbum Reporter: Victor Lobo <victor.ip.lobo>
Component: DatebarAssignee: KPhotoAlbum Bugs <kpabugs>
Status: VERIFIED FIXED    
Severity: crash CC: johannes
Priority: NOR    
Version: GIT master   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Victor Lobo 2023-11-12 01:06:53 UTC
SUMMARY
KPhotoAlbum git master crashes when range selected in Datebar extends out of main screen. Crash occurs only in the git master version (not in 5.11.0)


STEPS TO REPRODUCE
1. Open KPhotoAlbum
2. Left Click below the timeline in the Datebar to select a date
3. Start dragging the mouse to the left or right to select a range
4. Move the cursor to edge/outside the main window
5. Crash


OBSERVED RESULT
Crash

EXPECTED RESULT
No crash

SOFTWARE/OS VERSIONS
Linux: openSUSE Tumbleweed 20230906; Kernel Version: 6.4.12-1-default (64-bit)
KDE Plasma Version: 5.27.7
KDE Frameworks Version: 5.109.0
Qt Version: 5.15.10
KPhotoAlbum development version latest git master v5.11.0-186-g2a4637b6


ADDITIONAL INFORMATION
1. Crash is reproducible every time the steps are followed.
2. Crash occurs even in the demo database.


Backtrace:
Application: KPhotoAlbum (kphotoalbum), signal: Aborted

[KCrash Handler]
#4  0x00007faca7091e0c in __pthread_kill_implementation () from /lib64/libc.so.6
#5  0x00007faca703f0e6 in raise () from /lib64/libc.so.6
#6  0x00007faca70268d7 in abort () from /lib64/libc.so.6
#7  0x00007faca78bb4f9 in qt_message_fatal (message=<synthetic pointer>..., context=...) at global/qlogging.cpp:1914
#8  QMessageLogger::fatal (this=this@entry=0x7ffdc311c2b8, msg=msg@entry=0x7faca7bd2028 "ASSERT failure in %s: \"%s\", file %s, line %d") at global/qlogging.cpp:893
#9  0x00007faca78ba78c in qt_assert_x (where=<optimized out>, what=<optimized out>, file=<optimized out>, line=<optimized out>) at global/qglobal.cpp:3399
#10 0x000000000047a74b in DateBar::DateBarWidget::unitAtPos (this=0x1bb9860, x=-2) at /home/victor/kphotoalbum/DateBar/DateBarWidget.cpp:920
#11 0x0000000000481099 in DateBar::SelectionHandler::mouseMoveEvent (this=0x2132860, x=-2) at /home/victor/kphotoalbum/DateBar/MouseHandler.cpp:78
#12 0x00000000004787c2 in DateBar::DateBarWidget::mouseMoveEvent (this=0x1bb9860, event=0x7ffdc311c900) at /home/victor/kphotoalbum/DateBar/DateBarWidget.cpp:597
#13 0x00007faca87e6d68 in QWidget::event (this=0x1bb9860, event=0x7ffdc311c900) at kernel/qwidget.cpp:9045
#14 0x0000000000475abb in DateBar::DateBarWidget::event (this=0x1bb9860, event=0x7ffdc311c900) at /home/victor/kphotoalbum/DateBar/DateBarWidget.cpp:158
#15 0x00007faca87a519e in QApplicationPrivate::notify_helper (this=this@entry=0x1a251e0, receiver=receiver@entry=0x1bb9860, e=e@entry=0x7ffdc311c900) at kernel/qapplication.cpp:3640
#16 0x00007faca87ad5cf in QApplication::notify (this=<optimized out>, receiver=<optimized out>, e=0x7ffdc311c900) at kernel/qapplication.cpp:3084
#17 0x00007faca7aed568 in QCoreApplication::notifyInternal2 (receiver=0x1bb9860, event=0x7ffdc311c900) at kernel/qcoreapplication.cpp:1064
#18 0x00007faca7aed73e in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#19 0x00007faca87ab92e in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x1bb9860, event=event@entry=0x7ffdc311c900, alienWidget=<optimized out>, nativeWidget=0x1c8b630, buttonDown=buttonDown@entry=0x7faca8cf2330 <qt_button_down>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2622
#20 0x00007faca87ff7fd in QWidgetWindow::handleMouseEvent (this=this@entry=0x1f3c6f0, event=event@entry=0x7ffdc311cbb0) at kernel/qwidgetwindow.cpp:684
#21 0x00007faca8802d1f in QWidgetWindow::event (this=0x1f3c6f0, event=0x7ffdc311cbb0) at kernel/qwidgetwindow.cpp:300
#22 0x00007faca87a519e in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x1f3c6f0, e=0x7ffdc311cbb0) at kernel/qapplication.cpp:3640
#23 0x00007faca7aed568 in QCoreApplication::notifyInternal2 (receiver=0x1f3c6f0, event=0x7ffdc311cbb0) at kernel/qcoreapplication.cpp:1064
#24 0x00007faca7aed73e in QCoreApplication::sendSpontaneousEvent (receiver=<optimized out>, event=<optimized out>) at kernel/qcoreapplication.cpp:1474
#25 0x00007faca7f7d0eb in QGuiApplicationPrivate::processMouseEvent (e=0x21b4e70) at kernel/qguiapplication.cpp:2285
#26 0x00007faca7f5036c in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#27 0x00007fac9bf1c1aa in xcbSourceDispatch (source=<optimized out>) at qxcbeventdispatcher.cpp:105
#28 0x00007faca4124ef0 in ?? () from /lib64/libglib-2.0.so.0
#29 0x00007faca4126b18 in ?? () from /lib64/libglib-2.0.so.0
#30 0x00007faca41271cc in g_main_context_iteration () from /lib64/libglib-2.0.so.0
#31 0x00007faca7b464a6 in QEventDispatcherGlib::processEvents (this=0x1aff7c0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#32 0x00007faca7aebffb in QEventLoop::exec (this=this@entry=0x7ffdc311cee0, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#33 0x00007faca7af4490 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#34 0x0000000000472a60 in main (argc=2, argv=0x7ffdc311d5e8) at /home/victor/kphotoalbum/main.cpp:161
[Inferior 1 (process 5434) detached]
Comment 1 Johannes Zarl-Zierl 2023-11-12 17:08:55 UTC
Git commit a8ca10713a8f09be062f2776ab1e1e3dd162d129 by Johannes Zarl-Zierl.
Committed on 12/11/2023 at 18:08.
Pushed by johanneszarl into branch 'master'.

Fix failing assertion when datebar selection is extended beyond valid region.

M  +1    -0    CHANGELOG.md
M  +1    -1    DB/XML/FileReader.cpp
M  +6    -2    DateBar/DateBarWidget.cpp
M  +1    -1    DateBar/DateBarWidget.h
M  +14   -4    DateBar/MouseHandler.cpp

https://invent.kde.org/graphics/kphotoalbum/-/commit/a8ca10713a8f09be062f2776ab1e1e3dd162d129
Comment 2 Johannes Zarl-Zierl 2023-11-12 17:09:49 UTC
Great catch!
Comment 3 Victor Lobo 2023-11-18 16:30:21 UTC
Thanks! And thank you for fixing this.