avogadrolibs icon indicating copy to clipboard operation
avogadrolibs copied to clipboard

Consistent segfaults while manipulating bonds between independent carbon bonds + hydrogens

Open Makiah opened this issue 1 year ago • 2 comments

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

  • Avogadrolibs: 1.98.0-eed1ba848a8bbae6d50205eda16e1046a760e36e
  • Qt: 5.15.2 GCC 64-bit

Desktop version: (please complete the following information):

  • OS: Ubuntu
  • Version 22.04
  • Compiler N/A

Describe the bug Avogadro 2 will segfault and display some suboptimal behavior while manipulating bonds and hydrogens between two independent carbon atoms. I've narrowed one potential problematic sequence of events down to the following, for which I've attached screenshots in order to reproduce.

To Reproduce

  1. Open Avogadro 2, create two carbon atoms by left clicking with the "Draw" tool. step1
  2. Left click on the first carbon atom, and drag the resulting bond to the second carbon atom. You should see the following. Notably this hydrogen manipulation done after the bond manipulation is also incorrect, as the second carbon now has zero attached hydrogens: this seems related to https://github.com/OpenChemistry/avogadrolibs/issues/1478. Screenshot from 2023-12-03 18-55-41
  3. Remove the bond between the first and second carbon by right clicking it. Screenshot from 2023-12-03 18-56-01
  4. Remove the second carbon by right clicking it Screenshot from 2023-12-03 18-56-13
  5. Remove the first carbon by right clicking it. You'll notice a segfault prompted by a nullptr access to Molecule::bonds, I have a quick fix set up locally so I see the following. Screenshot from 2023-12-03 18-56-27 Screenshot from 2023-12-03 18-56-35

Working on understanding the root cause here to ideally address this issue and https://github.com/OpenChemistry/avogadrolibs/issues/1478 simultaneously.

Expected behavior No segfaults, valence shell of carbons correctly populated at each step in the above process (might split this into a couple separate PRs).

Screenshots Attached above

Makiah avatar Dec 04 '23 01:12 Makiah

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/

welcome[bot] avatar Dec 04 '23 01:12 welcome[bot]

Is this now fixed by #1493 ? I was never able to reproduce this, so I need to know if your patch fixed the underlying issue. Thanks.

ghutchis avatar Feb 12 '24 19:02 ghutchis