AddHydrogens() and subsequent GetX() causes segmentation fault

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

AddHydrogens() and subsequent GetX() causes segmentation fault

Peng Bai
Dear OpenBabel users,

I wanted to use the AddHydrogens() method from Python, and things work
fine if I create an OBMol object by reading in a file, but it crashes
with a segmentation fault if I used it as in the example below. I
tried it on different machines:

(1) Python 2.7.9
OpenBabel git:d56a5d compiled with gcc 5.1.0
or OpenBabel 2.3.2 compiled with gcc 4.9.2
(2) Python 2.7.10
OpenBabel git:d56a5d compiled with gcc 4.8

An example interactive session:

~~~
In [1]: import openbabel as ob
In [2]: obmol = ob.OBMol()
In [3]: obatom = obmol.NewAtom()
In [4]: obatom.SetAtomicNum(6)
In [5]: obatom.SetVector(1.0, 1.0, 1.0)
In [6]: obmol.NumAtoms()
Out[6]: 1
In [7]: obmol.AddHydrogens()
Out[7]: True
In [8]: obmol.NumAtoms()
Out[8]: 5
In [9]: obatom2 = obmol.GetAtom(2)
In [10]: obatom2.GetAtomicNum()
Out[10]: 1
In [11]: obatom2.GetAtomicMass()
Out[11]: 1.00794
In [12]: obatom2.GetX()
Segmentation fault
~~~

Any suggestions why this may happen? Thanks very much in advance!

Best regards,

Peng

------------------------------------------------------------------------------
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AddHydrogens() and subsequent GetX() causes segmentation fault

Andreas Kempe
The problem seems to be related to the internal coordinate pointers not being initialized correctly.
I suggest forcing a manual update after changing the molecule:

import openbabel as ob
obmol = ob.OBMol()
obmol.BeginModify()
obatom = obmol.NewAtom()
obatom.SetAtomicNum(6)
obatom.SetVector(1.0, 1.0, 1.0)
obmol.EndModify()
obmol.AddHydrogens()
obatom2 = obmol.GetAtom(2)
print obatom2.GetX()

-------- Original-Nachricht --------
Betreff: [Open Babel] AddHydrogens() and subsequent GetX() causes segmentation fault
Von: Peng Bai [hidden email]
An: [hidden email]
Datum: 07.04.2016 18:30
Dear OpenBabel users,

I wanted to use the AddHydrogens() method from Python, and things work
fine if I create an OBMol object by reading in a file, but it crashes
with a segmentation fault if I used it as in the example below. I
tried it on different machines:

(1) Python 2.7.9
OpenBabel <a class="moz-txt-link-freetext" href="git:d56a5d">git:d56a5d compiled with gcc 5.1.0
or OpenBabel 2.3.2 compiled with gcc 4.9.2
(2) Python 2.7.10
OpenBabel <a class="moz-txt-link-freetext" href="git:d56a5d">git:d56a5d compiled with gcc 4.8

An example interactive session:

~~~
In [1]: import openbabel as ob
In [2]: obmol = ob.OBMol()
In [3]: obatom = obmol.NewAtom()
In [4]: obatom.SetAtomicNum(6)
In [5]: obatom.SetVector(1.0, 1.0, 1.0)
In [6]: obmol.NumAtoms()
Out[6]: 1
In [7]: obmol.AddHydrogens()
Out[7]: True
In [8]: obmol.NumAtoms()
Out[8]: 5
In [9]: obatom2 = obmol.GetAtom(2)
In [10]: obatom2.GetAtomicNum()
Out[10]: 1
In [11]: obatom2.GetAtomicMass()
Out[11]: 1.00794
In [12]: obatom2.GetX()
Segmentation fault
~~~

Any suggestions why this may happen? Thanks very much in advance!

Best regards,

Peng

------------------------------------------------------------------------------
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss


------------------------------------------------------------------------------

_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

smime.p7s (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: AddHydrogens() and subsequent GetX() causes segmentation fault

Peng Bai
That solves the problem -- thank you!

Best regards,

Peng

On Fri, Apr 8, 2016 at 6:05 AM, Andreas Kempe
<[hidden email]> wrote:

> The problem seems to be related to the internal coordinate pointers not
> being initialized correctly.
> I suggest forcing a manual update after changing the molecule:
>
> import openbabel as ob
> obmol = ob.OBMol()
> obmol.BeginModify()
> obatom = obmol.NewAtom()
> obatom.SetAtomicNum(6)
> obatom.SetVector(1.0, 1.0, 1.0)
> obmol.EndModify()
> obmol.AddHydrogens()
> obatom2 = obmol.GetAtom(2)
> print obatom2.GetX()
>
> -------- Original-Nachricht --------
> Betreff: [Open Babel] AddHydrogens() and subsequent GetX() causes
> segmentation fault
> Von: Peng Bai <[hidden email]>
> An: [hidden email]
> Datum: 07.04.2016 18:30
>
> Dear OpenBabel users,
>
> I wanted to use the AddHydrogens() method from Python, and things work
> fine if I create an OBMol object by reading in a file, but it crashes
> with a segmentation fault if I used it as in the example below. I
> tried it on different machines:
>
> (1) Python 2.7.9
> OpenBabel git:d56a5d compiled with gcc 5.1.0
> or OpenBabel 2.3.2 compiled with gcc 4.9.2
> (2) Python 2.7.10
> OpenBabel git:d56a5d
>  compiled with gcc 4.8
>
> An example interactive session:
>
> ~~~
> In [1]: import openbabel as ob
> In [2]: obmol = ob.OBMol()
> In [3]: obatom = obmol.NewAtom()
> In [4]: obatom.SetAtomicNum(6)
> In [5]: obatom.SetVector(1.0, 1.0, 1.0)
> In [6]: obmol.NumAtoms()
> Out[6]: 1
> In [7]: obmol.AddHydrogens()
> Out[7]: True
> In [8]: obmol.NumAtoms()
> Out[8]: 5
> In [9]: obatom2 = obmol.GetAtom(2)
> In [10]: obatom2.GetAtomicNum()
> Out[10]: 1
> In [11]: obatom2.GetAtomicMass()
> Out[11]: 1.00794
> In [12]: obatom2.GetX()
> Segmentation fault
> ~~~
>
> Any suggestions why this may happen? Thanks very much in advance!
>
> Best regards,
>
> Peng
>
> ------------------------------------------------------------------------------
> _______________________________________________
> OpenBabel-discuss mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial! http://pubads.g.doubleclick.net/
gampad/clk?id=1444514301&iu=/ca-pub-7940484522588532
_______________________________________________
OpenBabel-discuss mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
Loading...