chemkit icon indicating copy to clipboard operation
chemkit copied to clipboard

malformed SDF string causes segfault

Open itdaniher opened this issue 12 years ago • 2 comments

import chemkit st = """ 2 1 0 0 0 0 999 V2000 ... -0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 ... 0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0""" f = chemkit.MoleculeFile() f.setFormat("sdf") True f.readString(st) Segmentation fault: 11

For your copying and pasting pleasure, the string above is:

' 2 1 0 0 0 0 999 V2000\n -0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n'

itdaniher avatar Jun 13 '12 02:06 itdaniher

Strange, I don't get a segfault when I run it. For me, the file is read successfully but only an empty molecule is returned. Could you run it under gdb and post the backtrace?

The main issue is that the file data doesn't start with the three comment lines. Prepending "\n\n\n" to the string resolves the issue and the ethane molecule is read correctly.

kylelutz avatar Jun 13 '12 13:06 kylelutz

Interesting, when I run from the string I copied and pasted above, it does not segfault. That said, https://gist.github.com/2923979 does segfault repeatably, and from within gdb.

Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0xfffffffffffffff0 0x0000000102670246 in MdlFileFormat::readSdfFile ()

itdaniher avatar Jun 13 '12 13:06 itdaniher