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

I ran into this issue today from a build that I did from HEAD.

This happens when I copy a section of my molecule and paste it back in. I do this in order to duplicate sections, for example when building polymers.

Avogadro crashes as soon as I try to connect the bonds of the pasted molecule to the original molecule.

Notably, it does NOT crash when I connect the bond from the original molecule to the newly pasted molecule.

This is the backtrace I got:

Error starting RPC server: "QLocalServer::listen: Address in use"                                                                                                                                                                                              
Starting new server.
Open Babel formats ready:  145
[New Thread 0x7fffb6a006c0 (LWP 2116424)]
[New Thread 0x7fffb60006c0 (LWP 2116425)]
[New Thread 0x7fffb56006c0 (LWP 2116426)]
/usr/include/c++/14.2.1/bits/stl_vector.h:1130: 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  0x00007ffff5ca5463 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:78
#2  0x00007ffff5c4c120 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff5c334c3 in __GI_abort () at abort.c:79
#4  0x00007ffff5ed3bb0 in std::__glibcxx_assert_fail
    (file=file@entry=0x7ffff710e8f8 "/usr/include/c++/14.2.1/bits/stl_vector.h", line=line@entry=1130, function=function@entry=0x7ffff70e8c98 "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=0x7ffff70de294 "__n < this->size()") at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/assert_fail.cc:41
#5  0x00007ffff712e0ab in std::vector<int, std::allocator<int> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14.2.1/bits/stl_vector.h:1128
#6  std::vector<int, std::allocator<int> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14.2.1/bits/stl_vector.h:1128
#7  Avogadro::Core::Graph::addEdge (this=this@entry=0x555555d78760, a=<optimized out>, a@entry=8, b=<optimized out>, b@entry=14) at /tmp/makepkg/avogadrolibs-git/src/avogadrolibs/avogadro/core/graph.cpp:204
#8  0x00007ffff7150648 in Avogadro::Core::Molecule::addBond (this=0x555555d78590, atom1=8, atom2=14, order=<optimized out>) at /tmp/makepkg/avogadrolibs-git/src/avogadrolibs/avogadro/core/molecule.cpp:677
#9  0x00007ffff76feaaa in QUndoStack::push(QUndoCommand*) () at /usr/lib/libQt5Widgets.so.5
#10 0x00007ffff7ee1ab5 in Avogadro::QtGui::RWMolecule::addBond (this=this@entry=0x555555d53360, atom1=atom1@entry=14, atom2=atom2@entry=8, order=1 '\001') at /tmp/makepkg/avogadrolibs-git/src/avogadrolibs/avogadro/qtgui/rwmolecule.cpp:274
1 Like

Thanks, thatā€™s helpful although I canā€™t reproduce it.

You said you ran your own build. Can you try a Debug build ā€¦ it looks like some of the key hints in the backtrace are optimized out.

I rebuilt Avogadroapp with debugging on, but in the process I also found out that my build was accidentally linking to my system version of Avogadrolibs 1.99.0-356-g96c13db8.

I built the entire OpenChemistry source tree and ran it from the separate build directory as mentioned here Building Source Code ā€” Avogadro 1.99.0 documentation, and it appears the bug was fixed in the latest versions of Avogadrolibs.

1 Like

Sorry to bring this up again, but I was mistaken.

I fixed up some linking issues I had, and the issue came back again, but I am narrowing down the root cause, and it has to do with some optimizations that are set on my Arch Linux system.

It seems when I set -D_GLIBCXX_ASSERTIONS in the CXXFLAGS it causes this issue. On Arch Linux this was enabled in my package manager.

I can send a message the Arch Linux folks to change this, but I am not sure if this is a compiler bug, Avogadro bug, or what at this point. I caught in the debugger as well. Picture attached.

Avogadro seems to run perfectly fine without this compiler flag.

These were all of my flags:

CFLAGS="-march=native -O2 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection"
CXXFLAGS="$CFLAGS -Wp,-D_GLIBCXX_ASSERTIONS"
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fuse-ld=mold"
LTOFLAGS="-flto=auto"

I can now reproduce it 100% of the time in CLion.

This is the most stubborn bug I have ever tracked down. It has taken me a week to narrow it down.

This is the backtrace from gdb:

(gdb) bt
#0  0x00007ffff0ca53f4 in ??? () at /usr/lib/libc.so.6
#1  0x00007ffff0c4c120 in raise () at /usr/lib/libc.so.6
#2  0x00007ffff0c334c3 in abort () at /usr/lib/libc.so.6
#3  0x00007fffec2d3bb0 in std::__glibcxx_assert_fail (file=<optimized out>, line=<optimized out>, function=<optimized out>, condition=<optimized out>) at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/assert_fail.cc:41
#4  0x00007ffff598e500 in std::vector<int, std::allocator<int> >::operator[] (this=0x555555d732c8, __n=22) at /usr/include/c++/14.2.1/bits/stl_vector.h:1130
#5  0x00007ffff599bdbc in Avogadro::Core::Graph::addEdge (this=0x555555d73290, a=1, b=11) at /home/dave/git/openchemistry/avogadrolibs/avogadro/core/graph.cpp:227
#6  0x00007ffff59bedb7 in Avogadro::Core::Molecule::addBond (this=0x555555d730c0, atom1=1, atom2=11, order=1 '\001') at /home/dave/git/openchemistry/avogadrolibs/avogadro/core/molecule.cpp:677
#7  0x00007ffff7460d48 in Avogadro::QtGui::Molecule::addBond (this=0x555555d730b0, atomId1=1, atomId2=11, order=1 '\001') at /home/dave/git/openchemistry/avogadrolibs/avogadro/qtgui/molecule.cpp:175
#8  0x00007ffff7473ee7 in Avogadro::QtGui::(anonymous namespace)::AddBondCommand::redo (this=0x555555736620) at /home/dave/git/openchemistry/avogadrolibs/avogadro/qtgui/rwmolecule_undo.h:407
#9  0x00007ffff6efeaaa in QUndoStack::push(QUndoCommand*) () at /usr/lib/libQt5Widgets.so.5

I also have a coredump but itā€™s pretty huge (2.3GB), and I donā€™t seem to be able to attach it, nor any compressed version of it here.

Regards,
Aeonik

1 Like

Posted on Arch Linux forums here:
https://bbs.archlinux.org/viewtopic.php?pid=2194502#p2194502

1 Like

Can you tell me a bit about what youā€™re doing in Avogadro? Like how many atoms are in each fragment? Could you upload the fragment or the file before the crash?

It looks like itā€™s trying to add a bond from atom 11 to atom 1, so itā€™s going to the various addBond and finally addEdge in the graph.cpp code.

That code is attempting to merge the two subgraphs (e.g., disconnected fragments):

    for (size_t i : m_subgraphToVertices[subgraphB]) {
      m_subgraphToVertices[subgraphA].insert(i);
      m_vertexToSubgraph[i] = subgraphA;
    }

The line in question would be m_vertexToSubgraph[i] ā€¦ which would make me think that i is an invalid index in m_vertexToSubgraph.

Dr. Hutchison,
I am attempting to build a Polypropylene polymer, I am interested in the electrical potential of the molecular orbits.

I use the drawing tool for the first three carbon atoms, copy the monomer (forgive me if I use the incorrect terminology, I only took high school chemistry). After I create the monomer, I copy and paste it, then connect the pasted carbon atom back to the original monomer.

You can see the screenshot attached showing the moment right before the crash.

Regards,
Aeonik

1 Like

Awesome. I can now reproduce this on an Ubuntu image with -Wp,-D_GLIBCXX_ASSERTIONS

Iā€™ll go take a look at the underlying cause. :slight_smile:

Based on other bug reports on GitHub, youā€™re not the only one seeing this crash.

Give this patch a try ā€“ seems to work for some limited testing:

Iā€™m not 100% sure why it gets into this condition, but this it at least good defensive programming.