pyinat / naturtag

Tag your nature photos with iNat taxonomy and observation metadata
https://naturtag.readthedocs.io
MIT License
37 stars 4 forks source link

Qt segfault #210

Open JWCook opened 2 years ago

JWCook commented 2 years ago

Sometimes the app suddenly crashes with no traceback. That likely means it's happening in C++ (Qt) due to invalid memory access.

This seems fairly difficult to debug. From a bit of reading, it seems one common cause is conflict between ownership of objects between python and Qt. So I can start by reviewing the widget and layout hierarchy, who owns what, and what happens when individual widgets are garbage collected.

Multithreaded processing is another likely culprit.

JWCook commented 4 months ago

It's likely the multithreading. I've temporarily set the worker thread count to 1 (configurable in settings file).

JWCook commented 2 months ago

Got a partial trace with gdb:

#0  0x00007fffc3bf76c3 in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
#1  0x00007fffc3bf7833 in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
#2  0x00007fffc3bcb8ea in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
#3  0x00007fffca84a7ca in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#4  0x00007fffca84292f in QObject::destroyed(QObject*) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#5  0x00007fffc3b763fb in QWidget::~QWidget() ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
#6  0x00007fffc44317d0 in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/QtWidgets.abi3.so
#7  0x00007fffca8433b2 in QObjectPrivate::deleteChildren() ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#8  0x00007fffc3b76408 in QWidget::~QWidget() ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
#9  0x00007fffc4262904 in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/QtWidgets.abi3.so
#10 0x00007fffca83dcb0 in QObject::event(QEvent*) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#11 0x00007fffc3b234f2 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Widgets.so.6
#12 0x00007fffca7ec18a in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#13 0x00007fffca7ef63d in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#14 0x00007fffcaaa3e93 in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#15 0x00007fffc81afd3b in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#16 0x00007fffc82052b8 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007fffc81ad3e3 in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007fffcaaa376a in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#19 0x00007fffca7f7963 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#20 0x00007fffca7f441e in QCoreApplication::exec() ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/Qt/lib/libQt6Core.so.6
#21 0x00007fffc45ffcbb in ?? ()
   from /home/jcook/.virtualenvs/naturtag/lib/python3.11/site-packages/PySide6/QtWidgets.abi3.so
#22 0x00007ffff7ba0ee2 in cfunction_vectorcall_NOARGS (func=0x7fffc495a5c0, args=<optimized out>,
    nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:486
#23 0x00007ffff7b4f5a8 in _PyObject_VectorcallTstate (kwnames=<optimized out>, nargsf=<optimized out>,
    args=<optimized out>, callable=0x7fffc495a5c0, tstate=0x7ffff7f775d8 <_PyRuntime+166328>)
    at ./Include/internal/pycore_call.h:92
#24 PyObject_Vectorcall (callable=0x7fffc495a5c0, args=<optimized out>, nargsf=<optimized out>,
    kwnames=<optimized out>) at Objects/call.c:299
#25 0x00007ffff7af173b in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>,
    throwflag=<optimized out>) at Python/ceval.c:4774
#26 0x00007ffff7c493cf in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff79e41b8,
    tstate=0x7ffff7f775d8 <_PyRuntime+166328>) at ./Include/internal/pycore_ceval.h:73
--Type <RET> for more, q to quit, c to continue without paging--
#27 _PyEval_Vector (args=0x0, argcount=0, kwnames=0x0, locals=0x7ffff73dea00, func=0x7ffff73ba020,
    tstate=0x7ffff7f775d8 <_PyRuntime+166328>) at Python/ceval.c:6439
#28 PyEval_EvalCode (co=co@entry=0x555556d81fc0, globals=globals@entry=0x7ffff73dea00,
    locals=locals@entry=0x7ffff73dea00) at Python/ceval.c:1154
#29 0x00007ffff7c452a0 in builtin_exec_impl (module=<optimized out>, closure=<optimized out>,
    locals=0x7ffff73dea00, globals=0x7ffff73dea00, source=0x555556d81fc0) at Python/bltinmodule.c:1077
#30 builtin_exec (module=<optimized out>, args=<optimized out>, nargs=<optimized out>, kwnames=<optimized out>)
    at Python/clinic/bltinmodule.c.h:465
#31 0x00007ffff7ba0c76 in cfunction_vectorcall_FASTCALL_KEYWORDS (func=0x7ffff7370f90, args=0x7ffff79e4180,
    nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:443
#32 0x00007ffff7b4f5a8 in _PyObject_VectorcallTstate (kwnames=<optimized out>, nargsf=<optimized out>,
    args=<optimized out>, callable=0x7ffff7370f90, tstate=0x7ffff7f775d8 <_PyRuntime+166328>)
    at ./Include/internal/pycore_call.h:92
#33 PyObject_Vectorcall (callable=0x7ffff7370f90, args=<optimized out>, nargsf=<optimized out>,
    kwnames=<optimized out>) at Objects/call.c:299
#34 0x00007ffff7af173b in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>,
    throwflag=<optimized out>) at Python/ceval.c:4774
#35 0x00007ffff7c49531 in _PyEval_EvalFrame (throwflag=0, frame=0x7ffff79e4020,
    tstate=0x7ffff7f775d8 <_PyRuntime+166328>) at ./Include/internal/pycore_ceval.h:73
#36 _PyEval_Vector (tstate=0x7ffff7f775d8 <_PyRuntime+166328>, func=<optimized out>, locals=<optimized out>,
    args=<optimized out>, argcount=<optimized out>, kwnames=<optimized out>) at Python/ceval.c:6439
#37 0x00007ffff7cb5fd7 in pymain_run_module (modname=<optimized out>, set_argv0=set_argv0@entry=1)
    at Modules/main.c:300
#38 0x00007ffff7cb66e3 in pymain_run_python (exitcode=0x7fffffffdab0) at Modules/main.c:595
#39 Py_RunMain () at Modules/main.c:680
#40 0x00007ffff7cb6f6e in pymain_main (args=0x7fffffffdbd0) at Modules/main.c:710
#41 Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:734
#42 0x00007ffff77e2d90 in __libc_start_call_main (main=main@entry=0x555555555060 <main>, argc=argc@entry=3,
    argv=argv@entry=0x7fffffffdd58) at ../sysdeps/nptl/libc_start_call_main.h:58
#43 0x00007ffff77e2e40 in __libc_start_main_impl (main=0x555555555060 <main>, argc=3, argv=0x7fffffffdd58,
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdd48)
    at ../csu/libc-start.c:392
#44 0x0000555555555095 in _start ()