#867 Seg Fault generated in ConnectTheDots

Pierre B

Originally thought to be a CIF problem (http://sourceforge.net/p/openbabel/bugs/742/) but the problem persists. Script attached should randomly reproduce the error. Generated it with openbabel 2.3.2 built on
gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
getting the following error:

glibc detected python: double free or corruption (!prev): 0x0000000000f281c0 ***
======= Backtrace: =========

Also reproduced the error with openbabel 2.3.2 built with
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
getting the following error:

Python(1529) malloc: *** error for object 0x7fe4ba47bf70: pointer being freed was not allocated

First generated the error for openbabel 2.3.1 as well built with the same gcc's above.

1 Attachments


  • Noel O'Boyle

    Noel O'Boyle - 2013-03-05

    Try atom = mol.NewAtom() instead and let me know if it works.

  • Richard West

    Richard West - 2013-03-05

    For me, replacing line 27 in the attached script obatom = ob.OBAtom() with obatom = obmol.NewAtom() makes it worse (crashes with malloc error after 3 iterations instead of 74 iterations). But I've just realized this computer has OpenBabel 2.3.1 so perhaps this isn't a very helpful comment. Will try again elsewhere.

  • Noel O'Boyle

    Noel O'Boyle - 2013-03-05

    Drat, and it's not reproducible on Windows. I'll have to wait a little to follow up.

    In short, it's a fight between Python and OB to figure out who owns the OBAtom object. When the OBMol is destroyed, it triggers destruction of its OBAtoms, but Python's garbage collector is also bent on destruction, and hence the double-free. It should probably be fixed in the python bindings by replacing NewAtom with a friendlier version.

    In the meanwhile, after "atom = mol.NewAtom()", can you add "atom.thisown = 0" and see if it improves things. For more info, see 31.4.2 at http://www.swig.org/Doc1.3/Python.html.

  • Pierre B

    Pierre B - 2013-03-05

    Did the same and replaced line 27 with obatom = obmol.NewAtom() and still got a malloc_error. Got through 11 iterations on the system built on gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6), and 3 iterations on the i686-apple-darwin11-llvm-gcc-4.2. Both are OpenBabel 2.3.2. At least it crashes consistently in both cases, before the number of iterations was random.

  • Pierre B

    Pierre B - 2013-03-05

    Just missed the Noel's last post. Added obatom.thisown = 0 after making the NewAtom and still crashed. The gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6) system gets through 4 iterations, 3 on the i686-apple-darwin11-llvm-gcc-4.2.

  • Noel O'Boyle

    Noel O'Boyle - 2013-03-05

    Ok. I've had a look. The following works for me. In the original script, add "obatom.thisown = False" right after obatom = ob.OBAtom().

  • Pierre B

    Pierre B - 2013-03-05

    It works!! On both systems as well. Many many thanks.

  • Geoff Hutchison

    Geoff Hutchison - 2014-03-15
    • status: open --> closed
  • Geoff Hutchison

    Geoff Hutchison - 2014-03-15

    This seems to be resolved. I'm closing it. Thanks!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks