#867 Seg Fault generated in ConnectTheDots

2.3.x
closed
nobody
None
1
2014-08-12
2013-02-25
Pierre B
No

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: =========
/lib64/libc.so.6[0x3aa0275716]
/home/me/lib/libopenbabel.so.4(_ZN9OpenBabel5OBMol14ConnectTheDotsEv+0x6cb)[0x7ffff13c805b]
/home/me/lib/_openbabel.so(+0x93e38)[0x7ffff1765e38]
/home/me/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x60db)[0x7ffff7d1556b]
/home/me/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x88e)[0x7ffff7d1691e]
/home/me/lib/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x563a)[0x7ffff7d14aca]
/home/me/lib/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x88e)[0x7ffff7d1691e]
/home/me/lib/libpython2.7.so.1.0(PyEval_EvalCode+0x32)[0x7ffff7d16a32]
/home/me/lib/libpython2.7.so.1.0(PyRun_FileExFlags+0xb0)[0x7ffff7d364d0]
/home/me/lib/libpython2.7.so.1.0(PyRun_SimpleFileExFlags+0xdc)[0x7ffff7d3669c]
/home/me/lib/libpython2.7.so.1.0(Py_Main+0xc5c)[0x7ffff7d4c0ec]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x3aa021ec9d]
python[0x400649]

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

Discussion

  • 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