Ifcopenshell: Segfault when creating geometry

Created on 13 Jan 2021  Â·  17Comments  Â·  Source: IfcOpenShell/IfcOpenShell

While testing IfcConvert from this build https://github.com/IfcOpenBot/IfcOpenShell/commit/e1b68dafa469e1f7549f4df500266075db2030a0#commitcomment-45887584 I'm seeing segfaults for various files. I haven't been able to isolate the problematic object so I'm going to email you an entire file that I'd rather not share publicly.

Relates to https://github.com/IfcOpenShell/IfcOpenShell/issues/841#issuecomment-759376680

Most helpful comment

@FreakTheMighty by the way, I've found using the BlenderBIM Add-on quite useful for isolating problematic objects. There is a feature which supports whitelisting, elements, and sometimes I print the name of the object being generated. There is also an "IFC Debug" panel that lets you dig into the shape representation tree, and one by one run create_shape on each subitem of the tree - especially useful for finding highly nested boolean operations where something causes a segfault.

If you'd like I can give you a little demo on it :)

All 17 comments

@FreakTheMighty by the way, I've found using the BlenderBIM Add-on quite useful for isolating problematic objects. There is a feature which supports whitelisting, elements, and sometimes I print the name of the object being generated. There is also an "IFC Debug" panel that lets you dig into the shape representation tree, and one by one run create_shape on each subitem of the tree - especially useful for finding highly nested boolean operations where something causes a segfault.

If you'd like I can give you a little demo on it :)

Recent versions of IfcConvert also have the -vv flag. That prints info on
the element currently being processed.

Op wo 13 jan. 2021 22:15 schreef Dion Moult notifications@github.com:

@FreakTheMighty https://github.com/FreakTheMighty by the way, I've
found using the BlenderBIM Add-on quite useful for isolating problematic
objects. There is a feature which supports whitelisting, elements, and
sometimes I print the name of the object being generated. There is also an
"IFC Debug" panel that lets you dig into the shape representation tree, and
one by one run create_shape on each subitem of the tree - especially
useful for finding highly nested boolean operations where something causes
a segfault.

If you'd like I can give you a little demo on it :)

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/IfcOpenShell/IfcOpenShell/issues/1258#issuecomment-759743894,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAILWVYNPO4LSNHPQ3TZ2FDSZYEPHANCNFSM4WBGJSPA
.

Thanks @Moult @aothms those are really helpful tips.

I can confirm that 32uecXxLHAvBNzQKHB18uk is the offending product. When I run with -vv this is the last log.

[Notice] {32uecXxLHAvBNzQKHB18uk} Adjusted edge end-point with distance 0.001587499999999872 on:
#438924=IfcCompositeCurve((#438722,#438729,#438736,#438744,#438751,#438759,#438766,#438774,#438781,#438789,#438796,#438804,#438811,#438819,#438826,#438833,#438840,#438848,#438855,#438863,#438870,#438878,#438885,#438893,#438900,#438908,#438915,#438923),.F.)

Also, in a simple python script calling create_shape on that product, I get the segfault. If, however, I try to extract that one element (I use BIMVision + plugin) the extracted example does not segfault which means that large file I emailed is still the smallest reproducible sample I have.

Nice! Didn't know about -vv, that's super useful!

@FreakTheMighty can you try IfcPatch using this recipe? https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.6.0/src/ifcpatch/recipes/ExtractElements.py - it's a very simple way to take out a single element (or any subset of elements). The query you feed it (i.e. args[0]) would be #32uecXxLHAvBNzQKHB18uk. (See more on writing filtering queries here: https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples#IFC_Query_Syntax )

@Moult patch worked, but the resulting file doesn't reproduce the error.


Very cool tool that patch thing is.

@FreakTheMighty maybe it is because the element has an opening (or projection, but most likely opening is my guess) relationship (which the patch doesn't consider). The opening boolean could be causing the segfault. If so, I'm curious if setting DISABLE_OPENING_SUBTRACTIONS in will cause the create_shape to succeed and not segfault.

Maybe you can help modify the patch's add_element function to also bring across any openings as an option?

@Moult nailed it! Disabling opening subtractions results in no segfault.

@FreakTheMighty fantastic! So it sounds like a modification of that patch recipe to include openings would be a super useful feature, especially when debugging in the future. Would you like to have a shot at modifying it? If not, I can find some time to look at it.

@Moult I’m up for trying. I’m going to be traveling tomorrow, so it may a little bit before I get around to if.

@Moult @aothms I've created a pull request for extracting openings. The resulting file does cause a segfault and is something I'm comfortable sharing. Its attached below.

out.zip

@aothms I can't reproduce the segfault when I build locally. I think one difference may be that I built OCE from source. 🤔 I'll have to see if I can test against oce from apt-get.

Yes I also had trouble reproducing on my local system. I kind of used to seeing files being affected by OCCT versions and compiler settings, but usually then it's not related to an IfcOpenShell commit and usually also not "various files", which is why I'm a bit surprised.

Good point about the commit and too bad it isn't failing easily for a local build. Perhaps I'll try manually bisecting builds from IfcOpenBot. Things seemed to work at c15fdc7 and are failing f2b645b, perhaps I get narrow in on when they started to fail.

@aothms here's what I've found digging through bot builds. It seems like the regression happened between c6a5bdf and aa49db0. Here's the diff between them, quite a lot, but perhaps something will pop out to us.


Bad

  • 7ae685d Dec 29, 2020
  • b08346c Nov 1, 2020
  • e08260d Oct 29, 2020
  • aa49db0 Oct 27, 2020 first broken

Good

  • c6a5bdf Sep 10, 2020 last working
  • c15fdc7 Aug 25, 2020

Thanks, this is gold, cross referencing with the isolated file there are some interesting bits in there.

When you change the precision on out.ifc, how does the file perform on your end?

Like:

#24=IFCGEOMETRICREPRESENTATIONCONTEXT($,'Model',3,0.000001,#22,#23);

Yes, indeed! 🤔 seems a bit odd that small and large values would work . . . is it a parsing issue?

Works

0.00001
0.01
0.1

Broken

0.0001

@aothms it seems that enabling our new flag STRICT_TOLERANCE avoids the segfault, while disabling it reproduces it.

ifc_openshell_settings.set(ifc_openshell_settings.STRICT_TOLERANCE, True)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Moult picture Moult  Â·  5Comments

Moult picture Moult  Â·  12Comments

Skyndia picture Skyndia  Â·  13Comments

brunoperdigao picture brunoperdigao  Â·  7Comments

Moult picture Moult  Â·  11Comments