Skip to content

IfcOpenShell Python segfaults when accessing context HasSubContexts after removal #1224

Description

@Moult

I don't really understand this, but I get a crash. Example code:

import ifcopenshell
f = ifcopenshell.file()
c = f.createIfcGeometricRepresentationContext()
print("1", c.HasSubContexts)
sc = f.create_entity("IfcGeometricRepresentationSubContext", **{"ParentContext": c})
print("2", c.HasSubContexts)
sc2 = f.create_entity("IfcGeometricRepresentationSubContext", **{"ParentContext": c})
print("3", c.HasSubContexts) # If I comment this line out, no segfault
f.remove(sc)
f.remove(sc2)
print("4", c.HasSubContexts)

This results in:

1 ()
2 (#2=IfcGeometricRepresentationSubContext($,$,*,*,*,*,#1,$,$,$),)
3 (#2=IfcGeometricRepresentationSubContext($,$,*,*,*,*,#1,$,$,$), #3=IfcGeometricRepresentationSubContext($,$,*,*,*,*,#1,$,$,$))
[1]    4518 segmentation fault  python test.py

If I comment out print("3", c.HasSubContexts), no segfault occurs:

1 ()
2 (#2=IfcGeometricRepresentationSubContext($,$,*,*,*,*,#1,$,$,$),)
4 ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions