Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000116PyRosetta[All Projects] Crashpublic2012-09-27 17:062012-09-28 15:55
Reporterevanbaugh 
Assigned To 
PrioritylowSeverityminorReproducibilityalways
StatusnewResolutionopen 
Platformx86OSLinuxOS VersionUbuntu
Product Version 
Fixed in Version 
Summary0000116: PyRosetta Constraint bug
DescriptionI cam across a bizarre bug today which has hampered me for a while (I just had no idea what was happening).

It seems that when you score a Pose with Constraints that were constructed in another namespace (such as a function) the scoring causes a SegFault

...I have no idea why this is happening...
Steps To Reproducefrom rosetta import *
init()

# example syntax to reproduce
# the first example here will work fine
#######################################

from rosetta.core.scoring.constraints import ConstantFunc, AtomPairConstraint

p = pose_from_sequence( 'AAA' ) # works on pose_from_pdb Pose's too
a1 = AtomID( 2 , 1 ) # residue 1 atom CA (2)
a2 = AtomID( 2 , 2 ) # residue 2 atom CA (2)
f = ConstantFunc( 0 ) # example function, has been seen with a few others

apc = AtomPairConstraint( a1 , a2 , f )
p.add_constraint( apc )

# make a scoring function
sc = ScoreFunction()
sc.set_weight( atom_pair_constraint , 1 )

sc( p )
# work's fine, all is well

#######################################
# the bad example

# make a demo function to generate the constraint
def make_constraint():
    a1 = AtomID( 2 , 1 ) # residue 1 atom CA (2)
    a2 = AtomID( 2 , 2 ) # residue 2 atom CA (2)
    f = ConstantFunc( 0 )

    apc = AtomPairConstraint( a1 , a2 , f )
    return apc

p = pose_from_sequence( 'AAA' )

apc = make_constraint()
p.add_constraint( apc )

sc( p ) # same ScoreFunction as above
# causes SeqFault

Additional Informationsometimes (at least with ConstantFunc) it returns a different error about not finding func and runs successfully on subsequent runs (I don't have the exact error now because of an annoying bug in mantis I just found...)
TagsNo tags attached.
Application(s) AffectedConstraint use in PyRosetta
Command Line Usedipython
Developer Options
Fixed in SVN Version
Attached Files

- Relationships

-  Notes
(0000112)
mpacella (Attentive Developer)
2012-09-28 15:55

Update: I found a workaround to this, but I think the issue should still be considered a bug (especially the fact that PyRosetta segfaults instead of printing something helpful.

You can get around this if you return a deep copy of the AtomPairConstraint in your function. So the code looks exactly like it does in the original report but the return line should look like this:

return AtomPairConstraint( ape ) #returning a deep copy of the atom pair constraint

I'm not entirely sure why this is necessary. It seems like the local variable "ape" must get deallocated when the function exits, hence the segfault when the score function tries to find it. However, if you do:

ape = make_constraint() #using the buggy version of make_constraint()
print ape

you get a genuine AtomPairConstraint object, not a pointer...

- Issue History
Date Modified Username Field Change
2012-09-27 17:06 evanbaugh New Issue
2012-09-28 15:55 mpacella Note Added: 0000112


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker