OtterBrowser / otter-browser

Otter Browser aims to recreate the best aspects of the classic Opera (12.x) UI using Qt5
https://otter-browser.org
GNU General Public License v3.0
1.79k stars 272 forks source link

Selecting or adding a mime in the download preferences crashes #1738

Closed ghost closed 1 year ago

ghost commented 1 year ago

OS: Linux Qt: 5.15.6 Distribution: Artix Linux 5.19.10-zen1-1-zen Otter: db537b4 and 44523b8 Arch: x86_64 glibc: 2.36-4

Selecting or attempting to add anything in the Download section under Preferences > Advanced terminates Otter with the following error:

terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 112) >= this->size() (which is 112)

Thread 1 "otter-browser" received signal SIGABRT, Aborted.
0x00007fffea8a149c in ?? () from /usr/lib/libc.so.6

This has been tested with the release (1.0.03) and the latest git, both with fresh configurations and clean caches. Backend does not make a difference in output or behavior. I have not attempted to test previous versions.

gdb Backtrace:

#0  0x00007fffea8a149c in  () at /usr/lib/libc.so.6
#1  0x00007fffea851958 in raise () at /usr/lib/libc.so.6
#2  0x00007fffea83b53d in abort () at /usr/lib/libc.so.6
#3  0x00007fffeaa99833 in __gnu_cxx::__verbose_terminate_handler() ()
    at /usr/src/debug/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#4  0x00007fffeaaa5cfc in __cxxabiv1::__terminate(void (*)()) (handler=<optimized out>)
    at /usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5  0x00007fffeaaa5d69 in std::terminate() ()
    at /usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#6  0x00007fffeaaa5fcd in __cxxabiv1::__cxa_throw(void*, std::type_info*, void (*)(void*))
    (obj=<optimized out>, tinfo=0x7fffeac291c8 <typeinfo for std::out_of_range>, dest=0x7fffeaabd710 <std::out_of_range::~out_of_range()>)
    at /usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_throw.cc:98
#7  0x00007fffeaa9c55b in std::__throw_out_of_range_fmt(char const*, ...)
    (__fmt=__fmt@entry=0x7fffeabb6568 "basic_string::at: __n (which is %zu) >= this->size() (which is %zu)") at /usr/src/debug/gcc/libstdc++-v3/src/c++11/functexcept.cc:101
#8  0x00007fffeab4ba64 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::at(unsigned long) const (this=<optimized out>, __n=<optimized out>)
    at /usr/src/debug/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:1242
#9  0x0000555555af7c79 in LibMimeApps::ConfigReader::unescape(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
    (string="Конфигуриране на устройствата за възпроизвеждане и запис на\\") at /mdia/Sources/otter-browser/3rdparty/libmimeapps/ConfigReader.cpp:135
#10 0x0000555555af76f9 in LibMimeApps::ConfigReader::ConfigReader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x7fffffffab40, path="/usr/share/applications/pavucontrol-qt.desktop") at /mdia/Sources/otter-browser/3rdparty/libmimeapps/ConfigReader.cpp:69
#11 0x0000555555afbe49 in LibMimeApps::DesktopEntry::DesktopEntry(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x5555568da8f0, baseDirectory="/usr/share/applications/", relative="pavucontrol-qt.desktop", language="en") at /mdia/Sources/otter-browser/3rdparty/libmimeapps/DesktopEntry.cpp:59
#12 0x0000555555aff808 in LibMimeApps::Index::processDesktopFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x7fffffffafa0, baseDirectory="/usr/share/applications/", relative="pavucontrol-qt.desktop") at /mdia/Sources/otter-browser/3rdparty/libmimeapps/Index.cpp:188
#13 0x0000555555aff0f1 in LibMimeApps::Index::processDesktopInDirectory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<LibMimeApps::file, std::allocator<LibMimeApps::file> > const&) (this=0x7fffffffafa0, baseDirectory="/usr/share/applications/", relative="", content=std::vector of length 252, capacity 256 = {...}) at /mdia/Sources/otter-browser/3rdparty/libmimeapps/Index.cpp:148
#14 0x0000555555afeef0 in LibMimeApps::Index::processDirectory(LibMimeApps::Index::lookupDirectory const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x7fffffffafa0, baseDirectory=..., relative="") at /mdia/Sources/otter-browser/3rdparty/libmimeapps/Index.cpp:138
#15 0x0000555555afecfd in LibMimeApps::Index::createBase() (this=0x7fffffffafa0) at /mdia/Sources/otter-browser/3rdparty/libmimeapps/Index.cpp:116
#16 0x0000555555afe794 in LibMimeApps::Index::Index(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (this=0x7fffffffafa0, language="en") at /mdia/Sources/otter-browser/3rdparty/libmimeapps/Index.cpp:51
#17 0x0000555555af18a9 in Otter::FreeDesktopOrgPlatformIntegration::getApplicationsForMimeType(QMimeType const&) (this=0x55555639bb30, mimeType=...) at /mdia/Sources/otter-browser/src/modules/platforms/freedesktoporg/FreeDesktopOrgPlatformIntegration.cpp:299
#18 0x0000555555787ca1 in Otter::Utils::getApplicationsForMimeType(QMimeType const&) (mimeType=...) at /mdia/Sources/otter-browser/src/core/Utils.cpp:642
#19 0x0000555555796476 in Otter::ApplicationComboBoxWidget::setMimeType(QMimeType const&) (this=0x55555648e030, mimeType=...) at /mdia/Sources/otter-browser/src/ui/ApplicationComboBoxWidget.cpp:123
#20 0x00005555559b219b in Otter::AdvancedPreferencesPage::updateDownloadsActions() (this=0x7fffc8007910) at /mdia/Sources/otter-browser/src/modules/windows/preferences/AdvancedPreferencesPage.cpp:265
#21 0x0000555555841d2a in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (Otter::AdvancedPreferencesPage::*)()>::call(void (Otter::AdvancedPreferencesPage::*)(), Otter::AdvancedPreferencesPage*, void**) (f=(void (Otter::AdvancedPreferencesPage::*)(Otter::AdvancedPreferencesPage * const)) 0x5555559b1d7a <Otter::AdvancedPreferencesPage::updateDownloadsActions()>, o=0x7fffc8007910, arg=0x7fffffffb370) at /usr/include/qt/QtCore/qobjectdefs_impl.h:152
#22 0x00005555558417c7 in QtPrivate::FunctionPointer<void (Otter::AdvancedPreferencesPage::*)()>::call<QtPrivate::List<>, void>(void (Otter::AdvancedPreferencesPage::*)(), Otter::AdvancedPreferencesPage*, void**) (f=(void (Otter::AdvancedPreferencesPage::*)(Otter::AdvancedPreferencesPage * const)) 0x5555559b1d7a <Otter::AdvancedPreferencesPage::updateDownloadsActions()>, o=0x7fffc8007910, arg=0x7fffffffb370) at /usr/include/qt/QtCore/qobjectdefs_impl.h:185
#23 0x00005555558413a0 in QtPrivate::QSlotObject<void (Otter::AdvancedPreferencesPage::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x555556842ae0, r=0x7fffc8007910, a=0x7fffffffb370, ret=0x0) at /usr/include/qt/QtCore/qobjectdefs_impl.h:418
#24 0x00007fffeb0bdf21 in  () at /usr/lib/libQt5Core.so.5
#25 0x0000555555633bc3 in Otter::ItemViewWidget::needsActionsUpdate() (this=0x7fffc8009390) at /mdia/Sources/otter-browser/build/otter-browser_autogen/YPKJ5OE7LN/moc_ItemViewWidget.cpp:582
#26 0x00005555557e4acb in Otter::ItemViewWidget::notifySelectionChanged() (this=0x7fffc8009390) at /mdia/Sources/otter-browser/src/ui/ItemViewWidget.cpp:824
#27 0x0000555555793dc4 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (Otter::ItemViewWidget::*)()>::call(void (Otter::ItemViewWidget::*)(), Otter::ItemViewWidget*, void**) (f=(void (Otter::ItemViewWidget::*)(Otter::ItemViewWidget * const)) 0x5555557e4a6c <Otter::ItemViewWidget::notifySelectionChanged()>, o=0x7fffc8009390, arg=0x7fffffffb590) at /usr/include/qt/QtCore/qobjectdefs_impl.h:152
#28 0x0000555555793d47 in QtPrivate::FunctionPointer<void (Otter::ItemViewWidget::*)()>::call<QtPrivate::List<>, void>(void (Otter::ItemViewWidget::*)(), Otter::ItemViewWidget*, void**) (f=(void (Otter::ItemViewWidget::*)(Otter::ItemViewWidget * const)) 0x5555557e4a6c <Otter::ItemViewWidget::notifySelectionChanged()>, o=0x7fffc8009390, arg=0x7fffffffb590) at /usr/include/qt/QtCore/qobjectdefs_impl.h:185
#29 0x0000555555793cb2 in QtPrivate::QSlotObject<void (Otter::ItemViewWidget::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x5555567ec9b0, r=0x7fffc8009390, a=0x7fffffffb590, ret=0x0) at /usr/include/qt/QtCore/qobjectdefs_impl.h:418
#30 0x00007fffeb0bdf21 in  () at /usr/lib/libQt5Core.so.5
#31 0x00007fffeb051cec in QItemSelectionModel::selectionChanged(QItemSelection const&, QItemSelection const&) () at /usr/lib/libQt5Core.so.5
#32 0x00007fffeb05750f in QItemSelectionModel::select(QItemSelection const&, QFlags<QItemSelectionModel::SelectionFlag>) () at /usr/lib/libQt5Core.so.5
#33 0x00007ffff7858378 in QTreeViewPrivate::select(QModelIndex const&, QModelIndex const&, QFlags<QItemSelectionModel::SelectionFlag>) () at /usr/lib/libQt5Widgets.so.5
#34 0x00007ffff784c8d2 in QTreeView::setSelection(QRect const&, QFlags<QItemSelectionModel::SelectionFlag>) () at /usr/lib/libQt5Widgets.so.5
#35 0x00007ffff77dcc93 in QAbstractItemView::mousePressEvent(QMouseEvent*) () at /usr/lib/libQt5Widgets.so.5
#36 0x00007ffff75af45b in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#37 0x00007ffff765d793 in QFrame::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#38 0x00007fffeb08d392 in QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#39 0x00007ffff7578b0c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#40 0x00007ffff757e339 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#41 0x00007fffeb08d728 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#42 0x00007ffff757c337 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () at /usr/lib/libQt5Widgets.so.5
#43 0x00007ffff75cd3b5 in  () at /usr/lib/libQt5Widgets.so.5
#44 0x00007ffff75cf15e in  () at /usr/lib/libQt5Widgets.so.5
#45 0x00007ffff7578b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#46 0x00007fffeb08d728 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#47 0x00007fffeb53f13c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/libQt5Gui.so.5
#48 0x00007fffeb528985 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Gui.so.5
#49 0x00007fffd812f6c0 in  () at /usr/lib/libQt5XcbQpa.so.5
#50 0x00007fffe811881b in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#51 0x00007fffe816eec9 in  () at /usr/lib/libglib-2.0.so.0
#52 0x00007fffe81170d2 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#53 0x00007fffeb0d80ac in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#54 0x00007fffeb085edc in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#55 0x00007ffff77734cb in QDialog::exec() () at /usr/lib/libQt5Widgets.so.5
#56 0x00005555557fe517 in Otter::MainWindow::triggerAction(int, QMap<QString, QVariant> const&, Otter::ActionsManager::TriggerType) (this=0x555555e391f0, identifier=170, parameters=..., trigger=Otter::ActionsManager::UnknownTrigger) at /mdia/Sources/otter-browser/src/ui/MainWindow.cpp:1144
#57 0x0000555555658ba5 in Otter::ActionExecutor::Object::triggerAction(int, QMap<QString, QVariant> const&, Otter::ActionsManager::TriggerType) (this=0x5555563ffba0, identifier=170, parameters=..., trigger=Otter::ActionsManager::UnknownTrigger) at /mdia/Sources/otter-browser/src/core/ActionExecutor.cpp:98
#58 0x000055555578d759 in Otter::Action::triggerAction(bool) (this=0x5555563ffb90, isChecked=false) at /mdia/Sources/otter-browser/src/ui/Action.cpp:97
#59 0x000055555578f0df in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<bool>, void, void (Otter::Action::*)(bool)>::call(void (Otter::Action::*)(bool), Otter::Action*, void**) (f=(void (Otter::Action::*)(Otter::Action * const, bool)) 0x55555578d5ae <Otter::Action::triggerAction(bool)>, o=0x5555563ffb90, arg=0x7fffffffccd0) at /usr/include/qt/QtCore/qobjectdefs_impl.h:152
#60 0x000055555578ee8c in QtPrivate::FunctionPointer<void (Otter::Action::*)(bool)>::call<QtPrivate::List<bool>, void>(void (Otter::Action::*)(bool), Otter::Action*, void**) (f=(void (Otter::Action::*)(Otter::Action * const, bool)) 0x55555578d5ae <Otter::Action::triggerAction(bool)>, o=0x5555563ffb90, arg=0x7fffffffccd0) at /usr/include/qt/QtCore/qobjectdefs_impl.h:185
#61 0x000055555578ec90 in QtPrivate::QSlotObject<void (Otter::Action::*)(bool), QtPrivate::List<bool>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x5555563ffb60, r=0x5555563ffb90, a=0x7fffffffccd0, ret=0x0) at /usr/include/qt/QtCore/qobjectdefs_impl.h:418
#62 0x00007fffeb0bdf21 in  () at /usr/lib/libQt5Core.so.5
#63 0x00007ffff756bec7 in QAction::triggered(bool) () at /usr/lib/libQt5Widgets.so.5
#64 0x00007ffff75718c7 in QAction::activate(QAction::ActionEvent) () at /usr/lib/libQt5Widgets.so.5
#65 0x00007ffff76f3e3b in  () at /usr/lib/libQt5Widgets.so.5
#66 0x00007ffff76f3f5d in  () at /usr/lib/libQt5Widgets.so.5
#67 0x0000555555820cb1 in Otter::Menu::mouseReleaseEvent(QMouseEvent*) (this=0x5555563ff560, event=0x7fffffffd3e0) at /mdia/Sources/otter-browser/src/ui/Menu.cpp:330
#68 0x00007ffff75af6e7 in QWidget::event(QEvent*) () at /usr/lib/libQt5Widgets.so.5
#69 0x00007ffff7578b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#70 0x00007ffff757e339 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#71 0x00007fffeb08d728 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#72 0x00007ffff757c337 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () at /usr/lib/libQt5Widgets.so.5
#73 0x00007ffff75cd894 in  () at /usr/lib/libQt5Widgets.so.5
#74 0x00007ffff75cf15e in  () at /usr/lib/libQt5Widgets.so.5
#75 0x00007ffff7578b1c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#76 0x00007fffeb08d728 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#77 0x00007fffeb53f13c in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/libQt5Gui.so.5
#78 0x00007fffeb528985 in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Gui.so.5
#79 0x00007fffd812f6c0 in  () at /usr/lib/libQt5XcbQpa.so.5
#80 0x00007fffe811881b in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#81 0x00007fffe816eec9 in  () at /usr/lib/libglib-2.0.so.0
#82 0x00007fffe81170d2 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#83 0x00007fffeb0d80ac in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#84 0x00007fffeb085edc in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#85 0x00007fffeb0909f9 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#86 0x0000555555654ebf in main(int, char**) (argc=1, argv=0x7fffffffde58) at /mdia/Sources/otter-browser/src/main.cpp:213
Emdek commented 1 year ago

@Wirlaburla, I think that LibMimeApps has some sort of issue with unescaping \\ in Конфигуриране на устройствата за възпроизвеждане и запис на\\.

Emdek commented 1 year ago

@Wirlaburla, try this diff:

diff --git a/3rdparty/libmimeapps/ConfigReader.cpp b/3rdparty/libmimeapps/ConfigReader.cpp
index cbf624a1a..817b22159 100644
--- a/3rdparty/libmimeapps/ConfigReader.cpp
+++ b/3rdparty/libmimeapps/ConfigReader.cpp
@@ -132,6 +132,12 @@ std::string ConfigReader::unescape(const std::string &string)
        if (string.at(i) == '\\')
        {
            ++i;
+
+           if (i >= string.length())
+           {
+               break;
+           }
+
            switch (string.at(i))
            {
            case 's':
ghost commented 1 year ago

@Emdek Seems it solved the issue. I can add, modify, and change settings in the Download preferences just fine now.

Emdek commented 1 year ago

@Wirlaburla, thanks for testing.