Crash when dragging atom over other atom to create bond

Environment Information

Avogadro version: 1.98.1; using the flathub repository
Operating system and version: Zorin 16 (based on Ubuntu 20.04)

Expected Behavior

The atom being dragged should be removed and bonds to it should transfer to the atom being dragged over.

Actual Behavior

Application crashes.

Steps to Reproduce

Drag an atom with a bond over another atom.

Note: deleting an atom with hydrogens attached also crashes, which might be related; something about the bond transfer/adjustment is highly unstable.

Let me see if I can understand what you’re doing. You’re using the edit tool, dragging to create a new atom and bond, and you drag over to an existing atom (e.g., to create a ring) … and there’s a crash?

I’m not super familiar with Flatpak - is it possible to get a crash log?

Can you try this with the AppImage, e.g. from Release Avogadro 1.98.1 · OpenChemistry/avogadrolibs · GitHub

I should mention that I’d ask you to try the AppImage or another package, because there was a bug like this, and I fixed it … maybe in 1.95 or 1.96? It’s possible there’s still something lurking, but I’d want to make sure it’s not something with the Flatpak build itself.

I tried the appimage, and it works as expected (no crash). I don’t know where a crash log for a flatpak would be located.

@kevinsmia1939 - is there a good way to get a crash log from the Flatpak build?

Just to check @InkTide - when you run the Flatpak, the About box says 1.98.1?

Hi @InkTide and @ghutchis
You can see the crash log by running avogadro2 Flatpak from the terminal. Then the crash log will be seen on the terminal.
flatpak run org.openchemistry.Avogadro2

Avogadro2 version is indeed 1.98.1
I can replicate the crash by creating two separate ethane molecule then try to create a bond between them.

"Checking for formatScripts scripts in path /home/kevin/.var/app/org.openchemistry.Avogadro2/data/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /app/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /usr/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /usr/share/runtime/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /run/host/user-share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /run/host/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /app/bin/../lib/avogadro2/scripts/formatScripts"
Open Babel formats ready:  142
/usr/include/c++/12.2.0/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

The latest message is displayed before crashing.

That’s only somewhat useful since it’s hard to know what Avogadro code called that std::vector [] code.

Is it possible to run the flatpak inside of gdb, e.g.

gdb flatpak
…
% run run org.openchemistry.Avogadro2
… [ use Avogadro to create the crash ]
% bt
… [ print a backtrace of the code causing the crash ]

Getting a backtrace from the crash would be super useful in fixing this crash.

Alternatively, I can create a pull request with a bunch of debugging added to the editor and that would help identify the crash point.

For example, does it crash immediately when creating the bond between them, or when hydrogen atoms are added after creating the bond.

Since I can’t reproduce it myself, I’d need either @kevinsmia1939 or @InkTide to help a bit here.

Thanks! Definitely want to fix this one.

I think I will need to recompile avogadrolib and avogadro2 with -DCMAKE_BUILD_TYPE=RelWithDebInfo

Anyway, to use gdb in Flatpak is to run this command.
flatpak run --command=bash --devel org.openchemistry.Avogadro2
Then
gdb /app/bin/avogadro2

After enable debuginfo in Flatpak, I can get the debug info now.
To get this error, run the following command.
flatpak run --command=bash --devel org.openchemistry.Avogadro2
gdb /app/bin/avogadro2
run

Try to crash Avogadro2

bt

(gdb) run
Starting program: /app/bin/avogadro2 

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.opensuse.org/
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
Downloading 0.03 MB separate debug info for system-supplied DSO at 0x7ffff7fc4000
[Thread debugging using libthread_db enabled]                                                                                                                                                                                                                               
Using host libthread_db library "/usr/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffecd22640 (LWP 21)]
[New Thread 0x7fffe7fff640 (LWP 22)]
Qt: Session management error: Could not open network socket
Using locale:  "en_US"
[New Thread 0x7fffda7ff640 (LWP 23)]
[New Thread 0x7fffd9ffe640 (LWP 24)]
Extension plugins dynamically found… 47
[New Thread 0x7fffd97fd640 (LWP 25)]
"Checking for energy scripts in path /home/kevin/.var/app/org.openchemistry.Avogadro2/data/OpenChemistry/Avogadro/energy"
"Checking for energy scripts in path /app/share/OpenChemistry/Avogadro/energy"
"Checking for energy scripts in path /usr/share/OpenChemistry/Avogadro/energy"
"Checking for energy scripts in path /usr/share/runtime/share/OpenChemistry/Avogadro/energy"
"Checking for energy scripts in path /run/host/user-share/OpenChemistry/Avogadro/energy"
"Checking for energy scripts in path /run/host/share/OpenChemistry/Avogadro/energy"
"Checking for energy scripts in path /app/bin/../lib/avogadro2/scripts/energy"
[Detaching after fork from child process 26]
"Cannot load script /app/lib/avogadro2/scripts/energy/ani2x.py"
[Detaching after fork from child process 27]
"Cannot load script /app/lib/avogadro2/scripts/energy/gaff.py"
[Detaching after fork from child process 28]
"Cannot load script /app/lib/avogadro2/scripts/energy/gfn1.py"
[Detaching after fork from child process 51]
"Cannot load script /app/lib/avogadro2/scripts/energy/gfn2.py"
[Detaching after fork from child process 74]
"Cannot load script /app/lib/avogadro2/scripts/energy/gfnff.py"
[Detaching after fork from child process 97]
"Cannot load script /app/lib/avogadro2/scripts/energy/mmff94.py"
[Detaching after fork from child process 98]
"Cannot load script /app/lib/avogadro2/scripts/energy/uff.py"
OBProcess::executeObabel: Running "/app/bin/obabel" "-L formats read"
[Detaching after fork from child process 99]
OBProcess::executeObabel: Running "/app/bin/obabel" "-L formats write"
[Detaching after fork from child process 100]
OBProcess::executeObabel: Running "/app/bin/obabel" "-L forcefields"
[Detaching after fork from child process 101]
OBProcess::executeObabel: Running "/app/bin/obabel" "-L charges"
[Detaching after fork from child process 102]
OBProcess::executeObabel: Running "/app/bin/obabel" "-V"
[Detaching after fork from child process 103]
"/app/bin/obabel"  found:  "/app/bin/obabel: Open Babel 3.1.0 -- Nov 18 2023 -- 04:35:44"
"Checking for commands scripts in path /home/kevin/.var/app/org.openchemistry.Avogadro2/data/OpenChemistry/Avogadro/commands"
"Checking for commands scripts in path /app/share/OpenChemistry/Avogadro/commands"
"Checking for commands scripts in path /usr/share/OpenChemistry/Avogadro/commands"
"Checking for commands scripts in path /usr/share/runtime/share/OpenChemistry/Avogadro/commands"
"Checking for commands scripts in path /run/host/user-share/OpenChemistry/Avogadro/commands"
"Checking for commands scripts in path /run/host/share/OpenChemistry/Avogadro/commands"
"Checking for commands scripts in path /app/bin/../lib/avogadro2/scripts/commands"
"Checking for inputGenerators scripts in path /home/kevin/.var/app/org.openchemistry.Avogadro2/data/OpenChemistry/Avogadro/inputGenerators"
"Checking for inputGenerators scripts in path /app/share/OpenChemistry/Avogadro/inputGenerators"
"Checking for inputGenerators scripts in path /usr/share/OpenChemistry/Avogadro/inputGenerators"
"Checking for inputGenerators scripts in path /usr/share/runtime/share/OpenChemistry/Avogadro/inputGenerators"
"Checking for inputGenerators scripts in path /run/host/user-share/OpenChemistry/Avogadro/inputGenerators"
"Checking for inputGenerators scripts in path /run/host/share/OpenChemistry/Avogadro/inputGenerators"
"Checking for inputGenerators scripts in path /app/bin/../lib/avogadro2/scripts/inputGenerators"
"Checking for charges scripts in path /home/kevin/.var/app/org.openchemistry.Avogadro2/data/OpenChemistry/Avogadro/charges"
"Checking for charges scripts in path /app/share/OpenChemistry/Avogadro/charges"
"Checking for charges scripts in path /usr/share/OpenChemistry/Avogadro/charges"
"Checking for charges scripts in path /usr/share/runtime/share/OpenChemistry/Avogadro/charges"
"Checking for charges scripts in path /run/host/user-share/OpenChemistry/Avogadro/charges"
"Checking for charges scripts in path /run/host/share/OpenChemistry/Avogadro/charges"
"Checking for charges scripts in path /app/bin/../lib/avogadro2/scripts/charges"
[Detaching after fork from child process 104]
"Cannot load script /app/lib/avogadro2/scripts/charges/antechamber.py"
[Detaching after fork from child process 105]
"Cannot load script /app/lib/avogadro2/scripts/charges/xtb.py"
"Checking for formatScripts scripts in path /home/kevin/.var/app/org.openchemistry.Avogadro2/data/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /app/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /usr/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /usr/share/runtime/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /run/host/user-share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /run/host/share/OpenChemistry/Avogadro/formatScripts"
"Checking for formatScripts scripts in path /app/bin/../lib/avogadro2/scripts/formatScripts"
[Detaching after fork from child process 106]
[Detaching after fork from child process 107]
[Detaching after fork from child process 108]
[New Thread 0x7fffcbfff640 (LWP 109)]
[New Thread 0x7fffcb7fe640 (LWP 110)]
[New Thread 0x7fffcaffd640 (LWP 111)]
Open Babel formats ready:  142
/usr/include/c++/12.2.0/bits/stl_vector.h:1123: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]: Assertion '__n < this->size()' failed.

Thread 1 "avogadro2" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44            return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff5891273 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff583f04e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff58287fc in __GI_abort () at abort.c:79
#4  0x00007ffff5ce1f9d in std::__glibcxx_assert_fail (file=file@entry=0x7ffff69b8110 "/usr/include/c++/12.2.0/bits/stl_vector.h", line=line@entry=1123, 
    function=function@entry=0x7ffff69b9a30 "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]", 
    condition=condition@entry=0x7ffff69b8000 "__n < this->size()") at ../../../../../libstdc++-v3/src/c++11/debug.cc:60
#5  0x00007ffff695c48c in std::vector<int, std::allocator<int> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/12.2.0/bits/stl_vector.h:1121
#6  std::vector<int, std::allocator<int> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/12.2.0/bits/stl_vector.h:1121
#7  Avogadro::Core::Graph::addEdge (this=this@entry=0x555555eb91d8, a=a@entry=0, b=b@entry=8) at /run/build/avogadrolibs/avogadrolibs/avogadro/core/graph.cpp:204
#8  0x00007ffff69757ff in Avogadro::Core::Molecule::addBond (this=0x555555eb9040, atom1=0, atom2=8, order=<optimized out>) at /run/build/avogadrolibs/avogadrolibs/avogadro/core/molecule.cpp:591
#9  0x00007ffff771d7c5 in QUndoStack::push (this=this@entry=0x555555e22cc0, cmd=<optimized out>, cmd@entry=0x555556a3b720) at util/qundostack.cpp:639
#10 0x00007ffff7f34eab in Avogadro::QtGui::RWMolecule::addBond (this=this@entry=0x555555e22ca0, atom1=atom1@entry=8, atom2=atom2@entry=0, order=<optimized out>) at /run/build/avogadrolibs/avogadrolibs/avogadro/qtgui/rwmolecule.cpp:273
#11 0x00007ffff7ac9c4f in Avogadro::QtGui::RWMolecule::addBond (order=<optimized out>, atom2=<synthetic pointer>..., atom1=<synthetic pointer>..., this=0x555555e22ca0) at /run/build/avogadrolibs/avogadrolibs/avogadro/qtgui/rwmolecule.h:769
#12 Avogadro::QtGui::RWMolecule::addBond (order=<optimized out>, atom2=<synthetic pointer>..., atom1=<synthetic pointer>..., this=<optimized out>) at /run/build/avogadrolibs/avogadrolibs/avogadro/qtgui/rwmolecule.h:763
#13 Avogadro::QtPlugins::Editor::atomLeftDrag (this=0x555555a8b210, e=<optimized out>) at /run/build/avogadrolibs/avogadrolibs/avogadro/qtplugins/editor/editor.cpp:596
#14 0x00007ffff7ac9fd0 in Avogadro::QtPlugins::Editor::mouseMoveEvent (this=0x555555a8b210, e=0x7fffffffca10) at /run/build/avogadrolibs/avogadrolibs/avogadro/qtplugins/editor/editor.cpp:180
#15 0x00007ffff7fb6da7 in Avogadro::QtOpenGL::GLWidget::mouseMoveEvent (this=0x555555a00710, e=0x7fffffffca10) at /run/build/avogadrolibs/avogadrolibs/avogadro/qtopengl/glwidget.cpp:270
#16 0x00007ffff73bce28 in QWidget::event (this=0x555555a00710, event=0x7fffffffca10) at kernel/qwidget.cpp:9045
#17 0x00007ffff737affe in QApplicationPrivate::notify_helper (this=this@entry=0x555555749560, receiver=receiver@entry=0x555555a00710, e=e@entry=0x7fffffffca10) at kernel/qapplication.cpp:3640
#18 0x00007ffff7383592 in QApplication::notify (this=<optimized out>, receiver=0x555555a00710, e=<optimized out>) at kernel/qapplication.cpp:3084
#19 0x00007ffff62ced98 in QCoreApplication::notifyInternal2 (receiver=0x555555a00710, event=0x7fffffffca10) at kernel/qcoreapplication.cpp:1064
#20 0x00007ffff738169e in QApplicationPrivate::sendMouseEvent (receiver=receiver@entry=0x555555a00710, event=event@entry=0x7fffffffca10, alienWidget=<optimized out>, nativeWidget=0x7fffffffd1c0, buttonDown=buttonDown@entry=0x7ffff78c29f0 <qt_button_down>, 
    lastMouseReceiver=..., spontaneous=true, onlyDispatchEnterLeave=false) at kernel/qapplication.cpp:2622
#21 0x00007ffff73d5c5e in QWidgetWindow::handleMouseEvent (this=0x55555602e2b0, event=0x7fffffffccc0) at kernel/qwidgetwindow.cpp:684
#22 0x00007ffff73d9100 in QWidgetWindow::event (this=0x55555602e2b0, event=0x7fffffffccc0) at kernel/qwidgetwindow.cpp:300
#23 0x00007ffff737affe in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x55555602e2b0, e=0x7fffffffccc0) at kernel/qapplication.cpp:3640
#24 0x00007ffff62ced98 in QCoreApplication::notifyInternal2 (receiver=0x55555602e2b0, event=0x7fffffffccc0) at kernel/qcoreapplication.cpp:1064
#25 0x00007ffff6b571bd in QGuiApplicationPrivate::processMouseEvent (e=0x55555609ac40) at kernel/qguiapplication.cpp:2278
#26 0x00007ffff6b2a0bc in QWindowSystemInterface::sendWindowSystemEvents (flags=flags@entry=...) at kernel/qwindowsysteminterface.cpp:1169
#27 0x00007fffed50992a in xcbSourceDispatch (source=source@entry=0x555555800e80) at qxcbeventdispatcher.cpp:105
#28 0x00007ffff3320d71 in g_main_dispatch (context=0x7fffe8005010) at ../glib/gmain.c:3419
#29 g_main_context_dispatch (context=0x7fffe8005010) at ../glib/gmain.c:4137
#30 0x00007ffff3377028 in g_main_context_iterate.constprop.0 (context=context@entry=0x7fffe8005010, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4213
#31 0x00007ffff331e4a3 in g_main_context_iteration (context=0x7fffe8005010, may_block=1) at ../glib/gmain.c:4278
#32 0x00007ffff6326ae6 in QEventDispatcherGlib::processEvents (this=0x5555557f47b0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#33 0x00007ffff62cd80b in QEventLoop::exec (this=this@entry=0x7fffffffd000, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69
#34 0x00007ffff62d5976 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121
#35 0x00007ffff6b4ac2c in QGuiApplication::exec () at kernel/qguiapplication.cpp:1863
#36 0x00007ffff737af75 in QApplication::exec () at kernel/qapplication.cpp:2832
#37 0x000055555556de13 in main (argc=<optimized out>, argv=<optimized out>) at /run/build/Avogadro2/Avogadro2/avogadro/avogadro.cpp:258
(gdb)

Thanks, that’s very helpful. I’ll take a look through the addBond code and the editor and see if I can figure out the trigger.

The build configurations can be found in the org.openchemistry.Avogadro2.yaml file in this repo which I enable the debuginfo. GitHub - kevinsmia1939/org.openchemistry.Avogadro2