Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in SelectionToolWidget::changeLayer (in Kalzium) #1193

Closed
Rayon340 opened this issue Nov 9, 2022 · 13 comments · Fixed by #1406 or #1408
Closed

Crash in SelectionToolWidget::changeLayer (in Kalzium) #1193

Rayon340 opened this issue Nov 9, 2022 · 13 comments · Fixed by #1406 or #1408
Assignees
Labels

Comments

@Rayon340
Copy link

Rayon340 commented Nov 9, 2022

Avogadro version: (please complete the following information from the About box):

  • Avogadrolibs: 1.97.0-1
  • Qt: 5.15.7

Desktop version: (please complete the following information):

  • OS: Arch Linux
  • Version [e.g. 10.12.4]
  • Compiler (if you built from source)

Describe the bug
Kalzium app crashes after clicking the Molecular Editor button. - 2022-11-09. Arch Linux. It happens also on Fedora 36 KDE.

This issue does not happen on Debian 11 and an older version of Kalzium.

The crash can be reproduced every time.

https://bugs.kde.org/show_bug.cgi?id=457191

KDE and Kalzium team told me that the issue concerns Avogadro and therefore to write it here.

To Reproduce
Steps to reproduce the behavior:

  1. On "Arch Linux 64 bit" or "Fedora 36 KDE 64 bit" download the Kalzium app either from pacman or dnf.
  2. Click on 'Molecular editor button'
  3. See the crash and the error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
Immagine 2022-11-09 093229
Immagine 2022-11-09 093247

Additional context
Add any other context about the problem here. Please consider uploading or linking test files.

@welcome
Copy link

welcome bot commented Nov 9, 2022

Thanks for opening your first issue here! Please try to include example files and screenshots if possible. If you're looking for support, please post on our forum: https://discuss.avogadro.cc/

@ghutchis
Copy link
Member

ghutchis commented Nov 9, 2022

I'm not sure I understand. We're not the Kalzium app. Is this an Avogadro2 bug?

@Rayon340
Copy link
Author

The crash appended in the Kalzium app. I know that you are not the Kalzium app. The Kalzium app team told me that the bug is not related to ther app, but that the crash depends on Avogadro and so to write here about it.

https://bugs.kde.org/show_bug.cgi?id=457191

@antonio-rojas
Copy link
Contributor

Backtrace

Application: Kalzium (kalzium), signal: Aborted
Content of s_kcrashErrorMessage: std::unique_ptr<char []> = {get() = <optimized out>}
[KCrash Handler]
#6  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#7  0x00007f9209ea16b3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#8  0x00007f9209e51958 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#9  0x00007f9209e3b53d in __GI_abort () at abort.c:79
#10 0x00007f9209e3b45c in __assert_fail_base (fmt=0x7f91ff9296d2 "%s%s%s:%u: %s%sLa declaraci\303\263n `%s' no se cumple.\n%n", assertion=0x7f920bd7b39c "m_activeMolecule != nullptr", file=0x7f920bd7aec0 "/usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/core/layermanager.cpp", line=97, function=<optimized out>) at assert.c:92
#11 0x00007f9209e4a486 in __GI___assert_fail (assertion=0x7f920bd7b39c "m_activeMolecule != nullptr", file=0x7f920bd7aec0 "/usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/core/layermanager.cpp", line=97, function=0x7f920bd7b1c8 "static std::size_t Avogadro::Core::LayerManager::layerCount()") at assert.c:101
#12 0x00007f920bd2c309 in Avogadro::Core::LayerManager::layerCount () at /usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/core/layermanager.cpp:95
#13 Avogadro::Core::LayerManager::layerCount () at /usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/core/layermanager.cpp:95
#14 0x00007f920be33d6a in Avogadro::QtGui::PluginLayerManager::layerCount (this=this@entry=0x559a6963c650) at /usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/qtgui/pluginlayermanager.cpp:143
#15 0x00007f920c739640 in Avogadro::QtPlugins::SelectionTool::applyLayer (layer=0, this=0x559a6963c5f0) at /usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/qtplugins/selectiontool/selectiontool.cpp:257
#16 Avogadro::QtPlugins::SelectionTool::qt_static_metacall (_o=0x559a6963c5f0, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /usr/src/debug/avogadrolibs/build/avogadro/qtplugins/selectiontool/Selection_autogen/EWIEGA46WW/moc_selectiontool.cpp:81
#17 0x00007f920a6bdc40 in doActivate<false> (sender=0x559a6962c490, signal_index=8, argv=0x7ffc480c0250) at kernel/qobject.cpp:3935
#18 0x00007f920c73a734 in Avogadro::QtPlugins::SelectionToolWidget::changeLayer (_t1=<optimized out>, this=<optimized out>) at /usr/src/debug/avogadrolibs/build/avogadro/qtplugins/selectiontool/Selection_autogen/EWIEGA46WW/moc_selectiontoolwidget.cpp:162
#19 Avogadro::QtPlugins::SelectionToolWidget::qt_static_metacall (_c=<optimized out>, _a=<optimized out>, _id=<optimized out>, _o=<optimized out>) at /usr/src/debug/avogadrolibs/build/avogadro/qtplugins/selectiontool/Selection_autogen/EWIEGA46WW/moc_selectiontoolwidget.cpp:88
#20 Avogadro::QtPlugins::SelectionToolWidget::qt_static_metacall (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=<optimized out>) at /usr/src/debug/avogadrolibs/build/avogadro/qtplugins/selectiontool/Selection_autogen/EWIEGA46WW/moc_selectiontoolwidget.cpp:81
#21 0x00007f920a6bdc40 in doActivate<false> (sender=0x559a6963eb40, signal_index=12, argv=0x7ffc480c0360) at kernel/qobject.cpp:3935
#22 0x00007f920b478c56 in QComboBox::currentIndexChanged (this=<optimized out>, _t1=<optimized out>) at .moc/moc_qcombobox.cpp:538
#23 0x00007f920b471187 in QComboBoxPrivate::_q_emitCurrentIndexChanged (this=0x559a69639c20, index=...) at ../../include/QtCore/../../src/corelib/itemmodels/qabstractitemmodel.h:62
#24 0x00007f920b47c98d in QComboBoxPrivate::setCurrentIndex (this=this@entry=0x559a69639c20, mi=...) at widgets/qcombobox.cpp:2331
#25 0x00007f920b47cb14 in QComboBox::setCurrentIndex (this=<optimized out>, index=0) at widgets/qcombobox.cpp:2293
#26 0x00007f920a6bdc40 in doActivate<false> (sender=0x559a6962bf90, signal_index=13, argv=0x7ffc480c05d0) at kernel/qobject.cpp:3935
#27 0x00007f920a6460b3 in QAbstractItemModel::rowsInserted (this=this@entry=0x559a6962bf90, _t1=..., _t2=<optimized out>, _t3=<optimized out>, _t4=...) at .moc/moc_qabstractitemmodel.cpp:592
#28 0x00007f920a646217 in QAbstractItemModel::endInsertRows (this=this@entry=0x559a6962bf90) at itemmodels/qabstractitemmodel.cpp:2780
#29 0x00007f920aea2c21 in QStandardItemModelPrivate::rowsInserted (count=1, row=<optimized out>, parent=<optimized out>, this=0x559a6962cd30) at itemmodels/qstandarditemmodel.cpp:665
#30 QStandardItemPrivate::insertRows (this=<optimized out>, row=<optimized out>, count=<optimized out>, items=...) at itemmodels/qstandarditemmodel.cpp:537
#31 0x00007f920b47ab5c in QStandardItemModel::insertRow (aitem=<optimized out>, arow=<optimized out>, this=0x559a6962bf90) at ../../include/QtGui/../../src/gui/itemmodels/qstandarditemmodel.h:447
#32 QComboBox::insertItem (this=this@entry=0x559a6963eb40, index=index@entry=0, icon=..., text=..., userData=...) at widgets/qcombobox.cpp:2444
#33 0x00007f920c738c4f in QComboBox::insertItem (auserData=..., atext=..., aindex=0, this=0x559a6963eb40) at /usr/include/qt/QtWidgets/qcombobox.h:303
#34 QComboBox::addItem (auserData=..., atext=..., this=0x559a6963eb40) at /usr/include/qt/QtWidgets/qcombobox.h:296
#35 Avogadro::QtPlugins::SelectionToolWidget::setDropDown (this=0x559a6962c490, current=0, max=1) at /usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/qtplugins/selectiontool/selectiontoolwidget.cpp:33
#36 0x00007f920ccc593b in Avogadro::QtOpenGL::GLWidget::setMolecule (this=this@entry=0x559a6961dd20, mol=mol@entry=0x559a695f31a0) at /usr/src/debug/avogadrolibs/avogadrolibs-1.97.0/avogadro/qtopengl/glwidget.cpp:48
#37 0x0000559a660d44a4 in KalziumGLWidget::KalziumGLWidget (this=<optimized out>, parent=<optimized out>, this=<optimized out>, parent=<optimized out>) at /usr/src/debug/kalzium/kalzium-22.12.1/compoundviewer/kalziumglwidget.cpp:73
#38 0x0000559a660d4fe1 in Ui_moleculeViewerForm::setupUi (moleculeViewerForm=0x559a6961f390, this=0x559a67ee28c8) at /usr/src/debug/kalzium/build/src/ui_moleculeviewerwidget.h:104
#39 MoleculeDialog::MoleculeDialog (this=<optimized out>, parent=<optimized out>, this=<optimized out>, parent=<optimized out>) at /usr/src/debug/kalzium/kalzium-22.12.1/src/tools/moleculeview.cpp:77
#40 0x0000559a6610c962 in Kalzium::slotMoleculeviewer (this=0x559a67a35b70) at /usr/src/debug/kalzium/kalzium-22.12.1/src/kalzium.cpp:356
#41 0x00007f920a6bda91 in QtPrivate::QSlotObjectBase::call (a=<optimized out>, r=<optimized out>, this=<optimized out>, this=<optimized out>, r=<optimized out>, a=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:398
#42 doActivate<false> (sender=0x559a6910f1b0, signal_index=4, argv=0x7ffc480c0bc0) at kernel/qobject.cpp:3923
#43 0x00007f920b36bec7 in QAction::triggered (this=this@entry=0x559a6910f1b0, _t1=<optimized out>) at .moc/moc_qaction.cpp:376
#44 0x00007f920b3718c7 in QAction::activate (this=0x559a6910f1b0, event=<optimized out>) at kernel/qaction.cpp:1161
#45 0x00007f920b46050e in QAbstractButtonPrivate::click (this=0x559a69432230) at widgets/qabstractbutton.cpp:399
#46 0x00007f920b460710 in QAbstractButton::mouseReleaseEvent (this=0x559a69432680, e=0x7ffc480c1150) at widgets/qabstractbutton.cpp:1045
#47 0x00007f920b55369f in QToolButton::mouseReleaseEvent (this=<optimized out>, e=<optimized out>) at widgets/qtoolbutton.cpp:622
#48 0x00007f920b3af837 in QWidget::event (this=0x559a69432680, event=0x7ffc480c1150) at kernel/qwidget.cpp:8671
#49 0x00007f920b378b5c in QApplicationPrivate::notify_helper (this=this@entry=0x559a678544d0, receiver=receiver@entry=0x559a69432680, e=e@entry=0x7ffc480c1150) at kernel/qapplication.cpp:3640
#50 0x00007f920b37e379 in QApplication::notify (this=<optimized out>, receiver=<optimized out>, e=0x7ffc480c1150) at kernel/qapplication.cpp:3084
#51 0x00007f920a68cf98 in QCoreApplication::notifyInternal2 (receiver=0x559a69432680, event=0x7ffc480c1150) at kernel/qcoreapplication.cpp:1064
#52 0x00007f920b37c377 in QApplicationPrivate::sendMouseEvent (receiver=0x559a69432680, event=0x7ffc480c1150, alienWidget=<optimized out>, nativeWidget=0x559a67a35b70, buttonDown=<optimized out>, lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2622
#53 0x00007f920b3cd505 in QWidgetWindow::handleMouseEvent (this=0x559a693d5ce0, event=0x7ffc480c14b0) at kernel/qwidgetwindow.cpp:683
#54 0x00007f920b3cf2ae in QWidgetWindow::event (this=0x559a693d5ce0, event=0x7ffc480c14b0) at kernel/qwidgetwindow.cpp:300
#55 0x00007f920b378b5c in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x559a693d5ce0, e=0x7ffc480c14b0) at kernel/qapplication.cpp:3640
#56 0x00007f920a68cf98 in QCoreApplication::notifyInternal2 (receiver=0x559a693d5ce0, event=0x7ffc480c14b0) at kernel/qcoreapplication.cpp:1064
#57 0x00007f920ab3f03c in QGuiApplicationPrivate::processMouseEvent (e=0x7f91f0005120) at kernel/qguiapplication.cpp:2285
#58 0x00007f920ab28885 in QWindowSystemInterface::sendWindowSystemEvents (flags=...) at kernel/qwindowsysteminterface.cpp:1169
#59 0x00007f9203ea6a55 in userEventSourceDispatch(_GSource*, int (*)(void*), void*) () from /usr/lib/libQt5WaylandClient.so.5
#60 0x00007f9206e6d87b in g_main_dispatch (context=0x7f91f8005010) at ../glib/glib/gmain.c:3454
#61 g_main_context_dispatch (context=0x7f91f8005010) at ../glib/glib/gmain.c:4172
#62 0x00007f9206ec4c89 in g_main_context_iterate.constprop.0 (context=0x7f91f8005010, block=1, dispatch=1, self=<optimized out>) at ../glib/glib/gmain.c:4248
#63 0x00007f9206e6c132 in g_main_context_iteration (context=0x7f91f8005010, may_block=1) at ../glib/glib/gmain.c:4313
#64 0x00007f920a6d7c8c in QEventDispatcherGlib::processEvents (this=0x559a6793b010, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#65 0x00007f920a68574c in QEventLoop::exec (this=0x7ffc480c1850, flags=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#66 0x00007f920a690269 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#67 0x00007f920ab39fe2 in QGuiApplication::exec () at kernel/qguiapplication.cpp:1870
#68 0x00007f920b376f2a in QApplication::exec () at kernel/qapplication.cpp:2832
#69 0x0000559a660c50ce in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/kalzium/kalzium-22.12.1/src/main.cpp:136
[Inferior 1 (process 87136) detached]

The crash happens in the m_activeMolecule != nullptr assert at
https://github.com/OpenChemistry/avogadrolibs/blob/master/avogadro/core/layermanager.cpp#L97

@ghutchis
Copy link
Member

What version of Avogadro is this? We've fixed this in more recent versions.

@antonio-rojas
Copy link
Contributor

What version of Avogadro is this? We've fixed this in more recent versions.

1.97.0, and it's also reproducible with latest git

@ghutchis ghutchis changed the title Kalzium crashes after clicking the Molecular Editor button Crash in SelectionToolWidget::changeLayer (in Kalzium) Apr 11, 2023
@ghutchis ghutchis self-assigned this Apr 11, 2023
@ghutchis ghutchis added the bug label May 10, 2023
@ghutchis ghutchis linked a pull request Oct 25, 2023 that will close this issue
@ghutchis
Copy link
Member

Okay, this took a while to track down, but it should be fixed in 1.98.

@antonio-rojas
Copy link
Contributor

The patch doesn't fix the problem, unfortunately. Kalzium still crashes with the same backtrace.

@ghutchis ghutchis reopened this Oct 25, 2023
@ghutchis
Copy link
Member

Thanks for the follow-up.

The whole chain of events seems to be triggered when setting up the SelectionToolWidget::setDropDown which should no longer be sending the currentIndexChanged signal. I'll look into it again a bit later this evening. I'd like to fix this for 1.98.

ghutchis added a commit to ghutchis/avogadrolibs that referenced this issue Oct 25, 2023
Only create the widget when needed, only connect the signal as-needed
Prevents a query for a layer before there's even a molecule

Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
@ghutchis ghutchis linked a pull request Oct 25, 2023 that will close this issue
@ghutchis
Copy link
Member

Okay, let's try this patch in #1408 - I think it should avoid the whole chain of events.

Please let me know if it solves the issue. (fingers crossed)

@github-actions
Copy link
Contributor

Here are the build results
Avogadro2.AppImage
macOS.dmg
Win64.exe
Artifacts will only be retained for 90 days.

@github-actions
Copy link
Contributor

Here are the build results
Avogadro2.AppImage
macOS.dmg
Win64.exe
Artifacts will only be retained for 90 days.

@antonio-rojas
Copy link
Contributor

This one works, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants