https://bugs.documentfoundation.org/show_bug.cgi?id=174398
Bug ID: 174398
Summary: CRASH: Search Commands (Shift+Esc) aborts on Up/Down
arrow when the results list is empty
Product: LibreOffice
Version: 26.8.2.2 release
Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: UNCONFIRMED
Severity: normal
Priority: medium
Component: Calc
Assignee: [email protected]
Reporter: [email protected]
Description:
On Fedora 45, LibreOffice Calc crashes when pressing either the Up or Down
arrow key in the Search Commands popup while its results list is empty.
When the results list contains entries, both arrow keys work normally. The
crash occurs specifically when navigating an empty list.
The terminal reports a failed std::clamp<int> assertion indicating that the
upper bound is below the lower bound.
I have encountered this behavior for several years, although the exact earliest
affected version has not been established.
Steps to Reproduce:
1. Start LibreOffice Calc
2. Press Shift+Esc to open Search Commands.
3. Leave the search field empty, with no entries in the results list.
4. Press the Down arrow key.
LibreOffice crashes immediately. Repeating these steps with the Up arrow key
also causes a crash.
For comparison, type a search that produces results before using the arrow
keys. Navigation then works normally.
Actual Results:
LibreOffice crashes immediately.
Terminal output:
/usr/include/c++/16/bits/stl_algo.h:3616: constexpr const _Tp& std::clamp(const
_Tp&, const _Tp&, const _Tp&) [with _Tp = int]: Assertion '!(__hi < __lo)'
failed.
This is followed by multiple GLib-GObject-CRITICAL messages reporting that
instances have no handler with the specified ID.
Expected Results:
Pressing Up or Down when the results list is empty should leave the popup open
without attempting to select an entry. LibreOffice should not crash.
Reproducible: Always
User Profile Reset: No
Additional Info:
Environment:
Fedora 45, x86-64.
Version: 26.8.2.2 (X86_64)
Build ID: 680(Build:2)
CPU threads: 32; OS: Linux 7.2; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Suspected cause:
In sfx2/source/commandpopup/CommandPopup.cxx, the published
CommandListBox::TreeViewKeyPress handler processes Up and Down using:
nNewIndex = std::clamp(nNewIndex, 0, mpCommandTreeView->n_children() - 1);
When n_children() returns 0, the bounds passed to std::clamp are 0 and -1. This
violates its precondition and matches the assertion reported above.
Published source reference:
https://docs.libreoffice.org/sfx2/html/CommandPopup_8cxx_source.html
Proposed fix:
Inside the Up/Down key-handling branch, return before calculating or selecting
an index when the list is empty:
if (mpCommandTreeView->n_children() == 0)
return true;
This would consume the keypress without calling std::clamp, select, or
set_cursor for an empty list.
--
You are receiving this mail because:
You are the assignee for the bug.