Quantomatic / zxlive

A graphical tool for the ZX calculus
Apache License 2.0
44 stars 14 forks source link

Application crashes in proof mode when clicking on rule category text instead of small arrow #228

Open Aerylia opened 4 months ago

Aerylia commented 4 months ago

Issue as described in the title. It seems to happen occasionally when clicking the rules themselves, but I have yet to identify where I need to be clicking for it to consistently happen.

I'm on MacBook Air M1 MacOs Sonoma 14.2.1

It seems to be a UI issue with QT throwing an uncaught exception.

The error:

qt.qpa.fonts: Populating font family aliases took 49 ms. Replace uses of missing font family "Monospace" with one that exists to avoid this cost. 2024-01-25 15:50:52.258 python[6110:10111293] The class 'NSOpenPanel' overrides the method identifier. This method is implemented by class 'NSWindow' 2024-01-25 15:51:41.788 python[6110:10111293] The class 'NSSavePanel' overrides the method identifier. This method is implemented by class 'NSWindow' Terminating app due to uncaught exception 'NSRangeException', reason: ' -[NSArrayM objectAtIndexedSubscript:]: index 6 beyond bounds [0 .. 5]' *** First throw call stack: ( 0 CoreFoundation 0x0000000184864570 exceptionPreprocess + 176 1 libobjc.A.dylib 0x0000000184355eb4 objc_exception_throw + 60 2 CoreFoundation 0x00000001847dad10 -[__NSCFString hasSuffix:] + 0 3 libqcocoa.dylib 0x000000012ecb8124 _ZN20QCocoaSystemTrayIcon13emitActivatedEv + 269336 4 libqcocoa.dylib 0x000000012ecb81a8 _ZN20QCocoaSystemTrayIcon13emitActivatedEv + 269468 5 libqcocoa.dylib 0x000000012ecb677c _ZN20QCocoaSystemTrayIcon13emitActivatedEv + 262768 6 QtWidgets 0x00000001186e50b0 ZN9QTreeView14currentChangedERK11QModelIndexS2 + 452 7 QtCore 0x000000011d3c5788 _ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 3780 8 QtCore 0x000000011d58a18c _ZN19QItemSelectionModel15setCurrentIndexERK11QModelIndex6QFlagsINS_13SelectionFlagEE + 324 9 QtWidgets 0x000000011866e31c _ZN17QAbstractItemView15mousePressEventEP11QMouseEvent + 880 10 QtWidgets 0x00000001186ddf7c _ZN9QTreeView15mousePressEventEP11QMouseEvent + 260 11 QtWidgets 0x0000000118442330 _ZN7QWidget5eventEP6QEvent + 132 12 QtWidgets 0x00000001184c6060 _ZN6QFrame5eventEP6QEvent + 56 13 QtWidgets 0x000000011866df3c _ZN17QAbstractItemView13viewportEventEP6QEvent + 988 14 QtWidgets 0x00000001186db37c _ZN9QTreeView13viewportEventEP6QEvent + 328 15 QtCore 0x000000011d37c25c _ZN23QCoreApplicationPrivate29sendThroughObjectEventFiltersEP7QObjectP6QEvent + 244 16 QtWidgets 0x00000001183f8fcc _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent + 240 17 QtWidgets 0x00000001183fb03c _ZN12QApplication6notifyEP7QObjectP6QEvent + 5100 18 QtCore 0x000000011d37bf88 _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent + 292 19 QtWidgets 0x00000001183f958c _ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_Ebb + 808 20 QtWidgets 0x00000001184569b0 _ZNK21QWidgetRepaintManager3rhiEv + 9912 21 QtWidgets 0x0000000118455c68 _ZNK21QWidgetRepaintManager3rhiEv + 6512 22 QtWidgets 0x00000001183f8fec _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent + 272 23 QtWidgets 0x00000001183f9e50 _ZN12QApplication6notifyEP7QObjectP6QEvent + 512 24 QtCore 0x000000011d37bf88 _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent + 292 25 QtGui 0x000000011e88a794 _ZN22QGuiApplicationPrivate17processMouseEventEPN29QWindowSystemInterfacePrivate10MouseEventE + 1748 26 QtGui 0x000000011e8e1aa4 _ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE + 396 27 libqcocoa.dylib 0x000000012ec5bd40 qt_plugin_instance + 54740 28 CoreFoundation 0x00000001847efa4c CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 28 29 CoreFoundation 0x00000001847ef9e0 CFRunLoopDoSource0 + 176 30 CoreFoundation 0x00000001847ef750 CFRunLoopDoSources0 + 244 31 CoreFoundation 0x00000001847ee340 __CFRunLoopRun + 828 32 CoreFoundation 0x00000001847ed9ac CFRunLoopRunSpecific + 608 33 HIToolbox 0x000000018ed9c448 RunCurrentEventLoopInMode + 292 34 HIToolbox 0x000000018ed9c0d8 ReceiveNextEventCommon + 220 35 HIToolbox 0x000000018ed9bfdc _BlockUntilNextEventMatchingListInModeWithFilter + 76 36 AppKit 0x0000000187fca8a4 _DPSNextEvent + 660 37 AppKit 0x00000001887a4980 -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716 38 AppKit 0x0000000187fbdd50 -[NSApplication run] + 476 39 libqcocoa.dylib 0x000000012ec5a644 qt_plugin_instance + 48856 40 QtCore 0x000000011d3858fc _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE + 532 41 QtCore 0x000000011d37c614 _ZN16QCoreApplication4execEv + 112 42 QtWidgets.abi3.so 0x000000011e2af2d4 _ZL26Sbk_QApplicationFunc_exec_P7_object + 164 43 python3.10 0x0000000104c63920 cfunction_vectorcall_NOARGS + 248 44 python3.10 0x0000000104d00630 call_function + 524 45 python3.10 0x0000000104cfbf50 _PyEval_EvalFrameDefault + 24792 46 python3.10 0x0000000104cf550c _PyEval_Vector + 2000 47 python3.10 0x0000000104d00630 call_function + 524 48 python3.10 0x0000000104cfbf50 _PyEval_EvalFrameDefault + 24792 49 python3.10 0x0000000104cf550c _PyEval_Vector + 2000 50 python3.10 0x0000000104cf4d0c PyEval_EvalCode + 120 51 python3.10 0x0000000104cf0918 builtin_exec + 836 52 python3.10 0x0000000104c63b44 cfunction_vectorcall_FASTCALL + 200 53 python3.10 0x0000000104d00630 call_function + 524 54 python3.10 0x0000000104cfc4a4 _PyEval_EvalFrameDefault + 26156 55 python3.10 0x0000000104cf550c _PyEval_Vector + 2000 56 python3.10 0x0000000104d00630 call_function + 524 57 python3.10 0x0000000104cfc4a4 _PyEval_EvalFrameDefault + 26156 58 python3.10 0x0000000104cf550c _PyEval_Vector + 2000 59 python3.10 0x0000000104d740d8 pymain_run_module + 272 60 python3.10 0x0000000104d73718 Py_RunMain + 1584 61 python3.10 0x0000000104d74b88 pymain_main + 1212 62 python3.10 0x0000000104bb9e4c main + 56 63 dyld 0x00000001843910e0 start + 2360 ) libc++abi: terminating due to uncaught exception of type NSException Abort trap: 6

RazinShaikh commented 4 months ago

This looks a bit difficult to debug and the error does not say what caused the problem. I am not able to reproduce this yet. It would help if you can figure out how to reproduce this crash.

Aerylia commented 4 months ago

It happens to me all the time, on my Macbook, not on Windows.

jvdwetering commented 4 months ago

I think @akissinger also had random crashes when on his mac.

akissinger commented 4 months ago

I was getting random crashes in Linux. It seemed to be somewhat sensitive to my Qt6/pyside version, but I never was able to pinpoint it

dlyongemallo commented 3 months ago

I believe this is due to a race condition where something is being used before it's initialised, due to a signal being delayed (which varies based on the OS and other factors). There's some code that's implicitly assuming a callback/slot is called before it actually has been.

Something like this is the cause of issue #120 as well. Unfortunately, these bugs are difficult to reproduce, because running a debugger/profiler alters the nature of the timings. (The term for such bugs is "Heisenbug"!)

Sometimes one can reason about the cause if one thinks carefully about the code logic. The error index 6 beyond bounds [0 .. 5] suggests that something had 6 items and that one item had been added to it, but an attempt was made to use that item before it was fully initialised. Since you say you were clicking on a list of rules, I would guess that you performed an operation that added a rule to a list of 6 existing ones, and then clicked on something that referenced the 7th rule before the data structures for it were fully initialised. It would be helpful to have more information about what exactly you were doing leading up to the crash.