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

malloc crash when building crystal supercell #824

Closed
drew-parsons opened this issue Feb 22, 2022 · 3 comments
Closed

malloc crash when building crystal supercell #824

drew-parsons opened this issue Feb 22, 2022 · 3 comments

Comments

@drew-parsons
Copy link
Contributor

Avogadro version:

  • Avogadrolibs: 1.95.1
  • Qt: 5.15.2

Desktop version:

  • OS: Linux (Debian unstable)
  • Version linux 5.16.7-2
  • Compiler gcc 11.2.0

Describe the bug

I'm reading a pdb file of a DNA or protein fragment and trying to extend the crystal to a supercell (the aim is to extend along the longitudinal axis to get a sense of the DNA helix).

But after pressing OK in the "Build Supercell" dialog box (e.g. after selecting 2×2x2), avogadro crashes, writing to stderr

free(): invalid pointer
Aborted

To Reproduce
Steps to reproduce the behavior:

  1. Open a pdb file, e.g. 2ztb.pdb from https://www.rcsb.org/structure/2ZTB
  2. Go to 'Crystal→Build Supercell'
  3. Select '2' for A, B and C repeat.
  4. Click 'OK'
  5. See error

Expected behavior

The fragment (unit cell) should be shown repeated according to the chosen supercell.

Backtrace

Running in gdb gets a backtrace:

$ gdb avogadro2
GNU gdb (Debian 10.1-2) 10.1.90.20210103-git
...
(gdb) run 2ztb.pdb
Starting program: /usr/bin/avogadro2 2ztb.pdb
...
Open Babel formats ready:  145
[New Thread 0x7fffb23fd640 (LWP 2288197)]
[New Thread 0x7fffb0e98640 (LWP 2288198)]
[Thread 0x7fffb23fd640 (LWP 2288197) exited]
free(): invalid pointer

Thread 1 "avogadro2" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1  0x00007ffff6290546 in __GI_abort () at abort.c:79
#2  0x00007ffff62e7eb8 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff6405a78 "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3  0x00007ffff62ef91a in malloc_printerr (str=str@entry=0x7ffff640374e "free(): invalid pointer") at malloc.c:5628
#4  0x00007ffff62f0cf4 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0) at malloc.c:4398
#5  0x00007ffff62f49b4 in __GI___libc_free (mem=<optimized out>) at malloc.c:3309
#6  0x00007ffff7dd9d21 in __gnu_cxx::new_allocator<unsigned long>::deallocate(unsigned long*, unsigned long) (__t=<optimized out>, __p=0x5555569465e0, this=0x555556936bf8) at /usr/include/c++/11/ext/new_allocator.h:132
#7  std::allocator_traits<std::allocator<unsigned long> >::deallocate(std::allocator<unsigned long>&, unsigned long*, unsigned long) (__n=<optimized out>, __p=0x5555569465e0, __a=...) at /usr/include/c++/11/bits/alloc_traits.h:492
#8  std::_Vector_base<unsigned long, std::allocator<unsigned long> >::_M_deallocate(unsigned long*, unsigned long) (__n=<optimized out>, __p=0x5555569465e0, this=0x555556936bf8) at /usr/include/c++/11/bits/stl_vector.h:354
#9  std::vector<unsigned long, std::allocator<unsigned long> >::_M_realloc_insert<unsigned long const&>(__gnu_cxx::__normal_iterator<unsigned long*, std::vector<unsigned long, std::allocator<unsigned long> > >, unsigned long const&)
    (this=0x555556936bf8, __position=283446366765517) at /usr/include/c++/11/bits/vector.tcc:500
#10 0x00007ffff7cee8a7 in std::vector<unsigned long, std::allocator<unsigned long> >::push_back(unsigned long const&) (__x=@0x7fffffffcc40: 8192, this=<optimized out>) at /usr/include/c++/11/bits/stl_vector.h:1198
#11 Avogadro::Core::Array<unsigned long>::push_back(unsigned long const&) (v=@0x7fffffffcc40: 8192, this=<optimized out>) at ./avogadro/core/array.h:250
#12 Avogadro::QtGui::Molecule::addAtom(unsigned char) (this=0x7fffffffce90, number=<optimized out>) at ./avogadro/qtgui/molecule.cpp:80
#13 0x00007ffff6da8314 in Avogadro::Core::CrystalTools::buildSupercell(Avogadro::Core::Molecule&, unsigned int, unsigned int, unsigned int) (molecule=..., a=a@entry=2, b=b@entry=2, c=c@entry=2) at /usr/include/c++/11/bits/stl_vector.h:1043
#14 0x00007ffff7d05c41 in Avogadro::QtGui::RWMolecule::buildSupercell(unsigned int, unsigned int, unsigned int) (this=0x555555c960d0, a=a@entry=2, b=b@entry=2, c=c@entry=2) at ./avogadro/qtgui/rwmolecule.cpp:520
#15 0x00007ffff7dcd0e4 in Avogadro::QtPlugins::SupercellDialog::buildSupercell(Avogadro::QtGui::Molecule&) (this=this@entry=0x7fffffffd0f0, mol=...) at ./avogadro/qtplugins/crystal/supercelldialog.cpp:58
#16 0x00007ffff7dcb944 in Avogadro::QtPlugins::Crystal::buildSupercell() (this=0x555555896a30) at ./avogadro/qtplugins/crystal/crystal.cpp:200
#17 0x00007ffff69351b8 in  () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#18 0x00007ffff7734dc2 in QAction::triggered(bool) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#19 0x00007ffff77379f4 in QAction::activate(QAction::ActionEvent) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff78bcf22 in  () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00007ffff78c4a01 in  () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#22 0x00007ffff777d4be in QWidget::event(QEvent*) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#23 0x00007ffff773b6bf in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#24 0x00007ffff77431c4 in QApplication::notify(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#25 0x00007ffff68feb1a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#26 0x00007ffff7741cd3 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#27 0x00007ffff7797093 in  () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#28 0x00007ffff77997f5 in  () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#29 0x00007ffff773b6bf in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Widgets.so.5
#30 0x00007ffff68feb1a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#31 0x00007ffff7045f77 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /lib/x86_64-linux-gnu/libQt5Gui.so.5
#32 0x00007ffff701c1bc in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib/x86_64-linux-gnu/libQt5Gui.so.5
#33 0x00007ffff1b6157a in  () at /lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#34 0x00007ffff511fcdb in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#35 0x00007ffff511ff88 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#36 0x00007ffff512003f in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#37 0x00007ffff6956154 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#38 0x00007ffff68fd52b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#39 0x00007ffff6905800 in QCoreApplication::exec() () at /lib/x86_64-linux-gnu/libQt5Core.so.5
#40 0x000055555556b9e6 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at ./avogadro/avogadro.cpp:183

Additional context

The SIGABRT is reproducible also for other pdb examples at https://www.rcsb.org/, but sometimes with a slightly different error message

malloc(): unsorted double linked list corrupted
@ghutchis
Copy link
Member

I'm pretty sure I know where this one is - it derives from the new layer code. I should have some time on Thursday to push a fix.

Is there a deadline for Ubuntu LTS?

@drew-parsons
Copy link
Contributor Author

Next Ubuntu LTS release is in April, but Ubuntu 22.04 Feature Freeze: Thursday, Feb 24, 2022 . So probably too late already but can try.

@drew-parsons
Copy link
Contributor Author

Since it's definitely a bug fix, we can probably get it approved during the feature freeze period, https://wiki.ubuntu.com/FeatureFreeze

ghutchis added a commit to ghutchis/avogadrolibs that referenced this issue Apr 28, 2022
Right now, this reverts OpenChemistry#806 but there's still some sort
of memory corruption when assigning one molecule to another

Also, it seems like File -> Import Crystal adds atoms that
don't have layer information

Signed-off-by: Geoff Hutchison <geoff.hutchison@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants