Nheko-Reborn / nheko

Desktop client for Matrix using Qt and C++20.
https://nheko-reborn.github.io/
GNU General Public License v3.0
1.94k stars 201 forks source link

Crash on an attempt to edit a sticker pack #1348

Open bodqhrohro opened 1 year ago

bodqhrohro commented 1 year ago

Describe the bug

terminate called after throwing an instance of 'std::out_of_range'                                                                                                         
  what():  map::at                                                                                                                                                         
Error: signal 6:                                                                                                                                                           
nheko(_Z17stacktraceHandleri+0x37)[0x564325b54d77]                                                                                                                         
/lib/x86_64-linux-gnu/libc.so.6(+0x3bf90)[0x7fb773c5af90]            
/lib/x86_64-linux-gnu/libc.so.6(+0x8accc)[0x7fb773ca9ccc]                                                                                                                  
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x12)[0x7fb773c5aef2]       
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3)[0x7fb773c45472]                                                                                                                
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x9d919)[0x7fb773e9d919]                                                                                                         
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa8e1a)[0x7fb773ea8e1a]                                                                                                         
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa8e85)[0x7fb773ea8e85]                                                                                                         
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa90d8)[0x7fb773ea90d8]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZSt20__throw_out_of_rangePKc+0x40)[0x7fb773ea0240]
nheko(_ZNK20SingleImagePackModel4dataERK11QModelIndexi+0x32c)[0x564325b2423c]
/usr/lib/x86_64-linux-gnu/libQt5QmlModels.so.5(+0x3f120)[0x7fb7737b6120]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZNK13QMetaProperty4readEPK7QObject+0x24a)[0x7fb7744bebea]
/usr/lib/x86_64-linux-gnu/libQt5QmlModels.so.5(+0x4ead8)[0x7fb7737c5ad8]
/usr/lib/x86_64-linux-gnu/libQt5QmlModels.so.5(+0x4edb2)[0x7fb7737c5db2]
/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5(_ZN20QQmlIncubatorPrivate8incubateER26QQmlInstantiationInterrupt+0xb65)[0x7fb775c8d3c5]
/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5(_ZN17QQmlEnginePrivate8incubateER13QQmlIncubatorP15QQmlContextData+0x22d)[0x7fb775c8d5fd]
/usr/lib/x86_64-linux-gnu/libQt5QmlModels.so.5(+0x5266f)[0x7fb7737c966f]  
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(+0x316a14)[0x7fb776316a14]
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(+0x3257b0)[0x7fb7763257b0]
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(+0x315203)[0x7fb776315203]          
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(+0x317f83)[0x7fb776317f83]
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(_ZN19QQuickWindowPrivate11polishItemsEv+0x142)[0x7fb776269a42]
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(+0x20bbcd)[0x7fb77620bbcd]                                                                                                      
/usr/lib/x86_64-linux-gnu/libQt5Quick.so.5(+0x20d013)[0x7fb77620d013]                                                                                                      
/usr/lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN7QWindow5eventEP6QEvent+0x115)[0x7fb774b493f5]
/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x7e)[0x7fb775362fae]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent+0x118)[0x7fb7744b16f8]
/usr/lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN22QGuiApplicationPrivate18processExposeEventEPN29QWindowSystemInterfacePrivate11ExposeEventE+0x8d)[0x7fb774b3e5cd]
/usr/lib/x86_64-linux-gnu/libQt5Gui.so.5(_ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0xac)[0x7fb774b11cac]
/usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5(+0x6deba)[0x7fb76f2c0eba]                                                                                                      
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x299)[0x7fb77411c7a9]
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x54a38)[0x7fb77411ca38]
/usr/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c)[0x7fb77411cacc]                                                    
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x66)[0x7fb774509836]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE+0x12b)[0x7fb7744b017b]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN16QCoreApplication4execEv+0x96)[0x7fb7744b82d6]
nheko(main+0xcd9)[0x5643257962d9]                                                    
/lib/x86_64-linux-gnu/libc.so.6(+0x2718a)[0x7fb773c4618a]                          
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85)[0x7fb773c46245]            
nheko(_start+0x21)[0x564325796c61]                                       

To Reproduce

  1. Open room settings.
  2. Create a room pack.
  3. Close all three popup windows.
  4. Open them once more.
  5. Add some more stickers to the pack.
  6. Close only the pack editor.
  7. Open the editor from the image pack settings again.

What happened?

No response

Expected behavior

No response

Screenshots

No response

Version

0.10.2

Operating system

Linux

Installation method

Some repository (AUR, homebrew, distribution repository, PPA, etc)

Qt version

5.15.8+dfsg-2

C++ compiler

No response

Desktop Environment

Compiz

Did you use profiles?

Relevant log output

No response

Backtrace

No response

bodqhrohro commented 1 year ago

The stages of how the pack was edited: 2023-02-03-025413_1920x1200_scrot After a restart, the editor opens well.

bodqhrohro commented 1 year ago

After adding a lot more stickers and closing/opening the editor, I got the same exception again not exactly when opening the editor, but when scrolling it down.

bodqhrohro commented 1 year ago

Another crash (possibly related, so I didn't create a separate issue):

terminate called after throwing an instance of 'std::out_of_range'
  what():  map::at
Error: signal 6:
nheko(_Z17stacktraceHandleri+0x37)[0x55b5c82f7d77]
/lib/x86_64-linux-gnu/libc.so.6(+0x3bf90)[0x7f2b64c5af90]
/lib/x86_64-linux-gnu/libc.so.6(+0x8accc)[0x7f2b64ca9ccc]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x12)[0x7f2b64c5aef2]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3)[0x7f2b64c45472]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x9d919)[0x7f2b64a9d919]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa8e1a)[0x7f2b64aa8e1a]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa8e85)[0x7f2b64aa8e85]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xa90d8)[0x7f2b64aa90d8]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZSt20__throw_out_of_rangePKc+0x40)[0x7f2b64aa0240]
nheko(_ZNK20SingleImagePackModel4dataERK11QModelIndexi+0x32c)[0x55b5c82c723c]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(+0x2523ea)[0x7f2b650523ea]
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5(_ZN18QAbstractItemModel11qt_metacallEN11QMetaObject4CallEiPPv+0x73)[0x7f2b65056153]
nheko(_ZN20SingleImagePackModel11qt_metacallEN11QMetaObject4CallEiPPv+0x15)[0x55b5c7f56615]
/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5(+0x2c6c93)[0x7f2b668c6c93]
/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5(+0x1a3521)[0x7f2b667a3521]
/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5(_ZNK3QV413QObjectMethod12callInternalEPKNS_5ValueES3_i+0x6c0)[0x7f2b667a53e0]
/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5(_ZN3QV47Runtime18CallPropertyLookup4callEPNS_15ExecutionEngineERKNS_5ValueEjPS4_i+0x8a)[0x7f2b667d48aa]
[0x7f2b5cdfd3ef]
  1. I assigned a sticker a key which duplicated an existing one.
  2. It falled back to the original filename "sticker.webp" (or possibly wasn't edited at all).
  3. I added three more stickers.
  4. Noticed this and clicked the "sticker.webp" item to correct it, and it crashed.

This time, I lost the editing progress, so it's a more severe issue than before.

bodqhrohro commented 1 year ago

Yeah, something weird happens.

  1. I attempted to add a sticker, changed the key to a unique one for sure, pressed Tab to go to the body field, but it didn't affect the item name and it remained "sticker.webp".
  2. Added another one which got initially named "sticker.webp" too.
  3. Clicked those items back and forth so they messed up.
  4. Pressed "Cancel".
  5. Opened the editor again, two offending items were still there.
  6. Deleted the last one.
  7. Clicked the remaining one: it crashed.
bodqhrohro commented 1 year ago

The shortcode which refused to save was "🎀".

bodqhrohro commented 1 year ago

The actual emoji doesn't matter actually: I noticed that this sticker was added twice.

The reliable way to reproduce the item confusion bug (which then leads to a crash) is to put a duplicate shortcode which doesn't save, and always use the same file name for every sticker.