IfcOpenShell / IfcOpenShell

Open source IFC library and geometry engine
GNU Lesser General Public License v3.0
1.88k stars 736 forks source link

IfcConvert crash on IfcWall with openings #231

Closed larsmoa closed 7 years ago

larsmoa commented 7 years ago

IfcConvert segfaults on a IfcWall with openings. I've created a minimal reproducible example: segfault.zip.

Stacktrace:

    frame #0: 0x0000000111bd4e44 libTKBRep.10.dylib'TopoDS_ListIteratorOfListOfShape::Initialize(this=0x00007fff4febc268, L=0x0000000000000010) at TCollection_ListIterator.gxx:48
    frame #1: 0x0000000111bd00f9 libTKBRep.10.dylib'TopoDS_Iterator::Initialize(this=0x00007fff4febc250, S=0x00007f98d0e6fc70, cumOri=true, cumLoc=true) at TopoDS_Iterator.cxx:39
    frame #2: 0x0000000114154b0b libTKBO.10.dylib'BOPTools_AlgoTools::GetEdgeOnFace(theE1=0x00007f98d3800038, theF2=0x00007f98d0e6fc70, theE2=0x00007fff4febc3c0) at BOPTools_AlgoTools.cxx:1604
    frame #3: 0x0000000114154f33 libTKBO.10.dylib'BOPTools_AlgoTools::IsInternalFace(theFace=0x00007f98c9aa49a0, theEdge=0x00007f98d3800038, theFace1=0x00007f98d0e6fc58, theFace2=0x00007f98d0e6fc70, theContext=0x00007f98c9ac7cc8) at BOPTools_AlgoTools.cxx:780
    frame #4: 0x000000011415530f libTKBO.10.dylib'BOPTools_AlgoTools::IsInternalFace(theFace=0x00007f98c9aa49a0, theEdge=0x00007f98d3800038, theLF=0x00007f98d0c05868, theContext=0x00007f98c9ac7cc8) at BOPTools_AlgoTools.cxx:741
    frame #5: 0x00000001141548df libTKBO.10.dylib'BOPTools_AlgoTools::IsInternalFace(theFace=0x00007f98c9aa49a0, theSolid=0x00007f98c9ac7ba8, theMEF=0x00007fff4febc8c0, theTol=0.000000099999999999999995, theContext=0x00007f98c9ac7cc8) at BOPTools_AlgoTools.cxx:676
    frame #6: 0x00000001140fc990 libTKBO.10.dylib'BOPAlgo_FillIn3DParts::Perform(this=0x00007f98c9ac7b68) at BOPAlgo_Builder_3.cxx:334
    frame #7: 0x0000000114106efc libTKBO.10.dylib'BOPCol_ContextFunctor<BOPAlgo_FillIn3DParts, BOPCol_NCVector<BOPAlgo_FillIn3DParts>, Handle_IntTools_Context, IntTools_Context>::operator(this=0x00007fff4febccc8, theIndex=1)(int) const at BOPCol_Parallel.hxx:142
    frame #8: 0x00000001141066c3 libTKBO.10.dylib'void OSD_Parallel::For<BOPCol_ContextFunctor<BOPAlgo_FillIn3DParts, BOPCol_NCVector<BOPAlgo_FillIn3DParts>, Handle_IntTools_Context, IntTools_Context> >(theBegin=0, theEnd=5, theFunctor=0x00007fff4febccc8, isForceSingleThreadExecution=true) at OSD_Parallel.hxx:262
    frame #9: 0x000000010ae77890 libTKBO.10.dylib`BOPCol_ContextCnt<BOPCol_ContextFunctor<BOPAlgo_FillIn3DParts, BOPCol_NCVector<BOPAlgo_FillIn3DParts>, Handle_IntTools_Context, IntTools_Context>, BOPCol_NCVector<BOPAlgo_FillIn3DParts>, Handle_IntTools_Context>::Perform(isRunParallel=false, theSolverVector=0x00007fff58f93390, theContext=0x00007f83080e9308) at BOPCol_Parallel.hxx:170
    frame #10: 0x000000010ae768f4 libTKBO.10.dylib`BOPAlgo_Builder::FillIn3DParts(this=0x00007f83080e9200, theInParts=0x00007fff58f93660, theDraftSolids=0x00007fff58f93638, (null)=0x00007fff58f93698) at BOPAlgo_Builder_3.cxx:663
    frame #11: 0x000000010ae73a33 libTKBO.10.dylib`BOPAlgo_Builder::FillImagesSolids(this=0x00007f83080e9200) at BOPAlgo_Builder_3.cxx:529
    frame #12: 0x000000010ae4f764 libTKBO.10.dylib`BOPAlgo_BOP::PerformInternal1(this=0x00007f83080e9200, theFiller=0x00007f8302db9a20) at BOPAlgo_BOP.cxx:474
    frame #13: 0x000000010ae56227 libTKBO.10.dylib`BOPAlgo_Builder::PerformInternal(this=0x00007f83080e9200, theFiller=0x00007f8302db9a20) at BOPAlgo_Builder.cxx:300
    frame #14: 0x000000010ae560c9 libTKBO.10.dylib`BOPAlgo_Builder::PerformWithFiller(this=0x00007f83080e9200, theFiller=0x00007f8302db9a20) at BOPAlgo_Builder.cxx:290
    frame #15: 0x000000010ae1ae1a libTKBO.10.dylib`BRepAlgoAPI_BooleanOperation::Build(this=0x00007fff58f93de8) at BRepAlgoAPI_BooleanOperation.cxx:354
    frame #16: 0x000000010746400b IfcConvert`IfcGeom::Kernel::convert_openings_fast(this=0x00007fff58f9be48, entity=0x00007f8300f66550, openings=0x00007fff58f94a40, entity_shapes=size=1, entity_trsf=0x00007fff58f94a50, cut_shapes=size=0) at IfcGeomFunctions.cpp:557

IfcOpenshell rev: 8481308 OpenCascade community edition rev: 731b697ec (branch 691patched_3)

PS! I've created a small tool for extracting parts of an IFC file by line-id for generating minimal reproducible examples. It's available at https://bitbucket.org/rendradev/ifcextract if that would be helpful in the future.

Stinkfist0 commented 7 years ago

I seem to be able to convert the file (on Windows). However, I am using OCCT (occt-V7_0_0-9059ca1) instead of OCE:

15:12:29>..\IfcConvert.exe segfault.ifc --verbose
IfcOpenShell IFC2X3 IfcConvert 0.5.0-dev
A file 'segfault.obj' already exists. Overwrite the existing file?
y
Scanning file...
Done scanning file
Creating geometry...
Done creating geometry (1 objects)

Log:
[Notice] exclude entities IfcOpeningElement IfcSpace
[Notice] Using world coords when writing WaveFront OBJ files
[Warning] {1WOps__U9F_eBVZkg0LQu3} Subtracting combined openings compound failed:
#280284=IfcWall('1WOps__U9F_eBVZkg0LQu3',#41,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:686430',$,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:680825',#265692,#280282,'686430')
[Error] {1WOps__U9F_eBVZkg0LQu3} Invalid result from subtraction:
#280284=IfcWall('1WOps__U9F_eBVZkg0LQu3',#41,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:686430',$,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:680825',#265692,#280282,'686430')
[Warning] {1WOps__U9F_eBVZkg0LQu3} Subtraction yields unchanged volume:
#280284=IfcWall('1WOps__U9F_eBVZkg0LQu3',#41,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:686430',$,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:680825',#265692,#280282,'686430')
[Error] {1WOps__U9F_eBVZkg0LQu3} Invalid result from subtraction:
#280284=IfcWall('1WOps__U9F_eBVZkg0LQu3',#41,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:686430',$,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:680825',#265692,#280282,'686430')
[Warning] {1WOps__U9F_eBVZkg0LQu3} Subtraction yields unchanged volume:
#280284=IfcWall('1WOps__U9F_eBVZkg0LQu3',#41,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:686430',$,'Basic Wall:Innervegg 95 stålstender 2x13 gips EI30:680825',#265692,#280282,'686430')
[Error] Unable to write output file 'segfault.obj'

Conversion took 31 seconds
larsmoa commented 7 years ago

I'll have a go with OCCT 7.0 (I didn't realize that version 7 was supported yet).

Stinkfist0 commented 7 years ago

Updated the output with --verbose switch.

larsmoa commented 7 years ago

I can confirm that this works correctly with OCCT 7.0 - thx :)

Stinkfist0 commented 7 years ago

IfcOpenShell's build scripts currently use older version of OCE/OCCT by default, so probably would be nice to find a fix for this that doesn't require newer OCCT.

larsmoa commented 7 years ago

Is there any reason why the build scripts should keep on using an older version by default?

aothms commented 7 years ago

Reasons include(d):