Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IfcConvert segfault with SVG output #2156

Closed
brunopostle opened this issue Apr 22, 2022 · 12 comments
Closed

IfcConvert segfault with SVG output #2156

brunopostle opened this issue Apr 22, 2022 · 12 comments

Comments

@brunopostle
Copy link
Contributor

At some point in the last few months my builds of IfcConvert started segfaulting when outputting SVG. Other output formats seem to be ok . Obviously this is a problem with my build environment, but I can't figure it out and need suggestions for somewhere to look next. Note that all my builds start with a clean git source tree.

The segfault happens almost immediately:

$ IfcConvert simple.ifc simple.svg
IfcOpenShell IfcConvert 0.7.0 (OCC 7.5.0)
Scanning file...
Done scanning file   
Parsing input file took 0 seconds
Creating geometry...
Segmentation fault (core dumped)

The stack trace doesn't show much:

           PID: 187314 (IfcConvert)
           UID: 1000 (bruno)
           GID: 1000 (bruno)
        Signal: 11 (SEGV)
     Timestamp: Fri 2022-04-22 18:32:33 BST (4h 57min ago)
  Command Line: IfcConvert simple.ifc simple.svg
    Executable: /usr/bin/IfcConvert
 Control Group: /user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-a1d1f3c7-83f3-4025-acd1-d38041226e9e.scope
          Unit: user@1000.service
     User Unit: vte-spawn-a1d1f3c7-83f3-4025-acd1-d38041226e9e.scope
         Slice: user-1000.slice
     Owner UID: 1000 (bruno)
       Boot ID: ddc7641d67c9404db36f63f1a8d31b20
    Machine ID: b1abb895ecaa4632b1660d4d0420f492
      Hostname: cluck
       Storage: /var/lib/systemd/coredump/core.IfcConvert.1000.ddc7641d67c9404db36f63f1a8d31b20.187314.1650648753000000.zst (present)
     Disk Size: 2.9M
       Message: Process 187314 (IfcConvert) of user 1000 dumped core.

                Found module linux-vdso.so.1 with build-id: 1e289edaaab9e832320ae02a0c5d0953c38b2de1
                Found module libftoa.so.0.4 with build-id: 29f1f511a0922a9bc87e20433fba76da15214570
                Found module libbz2.so.1 with build-id: 19ce300b78962ee0b113afb0f1016727a2f3c37b
                Found module libsz.so.2 with build-id: c69bcb83945ff4e25be01fc8e04ffb0545d1308e
                Found module libbuffer.so.0.4 with build-id: cfbb4dac66805927a7d9880ac0276ab210591a85
                Found module libpcre.so.1 with build-id: fcbdb4731e50f20a47b62341a6841dd616fe495d
                Found module libUTF.so.0.4 with build-id: b233a769b5825d77b9418f23f6f246251053aad1
                Found module libboost_iostreams.so.1.76.0 with build-id: bcf2126fab7972d12b5b9dc1b9e35ca0fa3673b5
                Found module libTKOffset.so.7 with build-id: 2130b06d825c391745432ce1f4bbb55f49f495eb
                Found module libTKFillet.so.7 with build-id: 100a90a339ca5f5ff19305865cb285b2ad6b97da
                Found module libTKBool.so.7 with build-id: 2b5ad243ed1ef4fa4dd2cbdbf963fa5f7ddfd6d0
                Found module libTKSTEPBase.so.7 with build-id: fdad9fef075576b11b2a68ca617f732e78d75dba
                Found module libTKSTEP209.so.7 with build-id: 488b6b4e720dfe63fcf3e352abaa92f004486703
                Found module libTKSTEPAttr.so.7 with build-id: 4d19b4a8000b6d299589cb6756c4d9dda00d0beb
                Found module ld-linux-x86-64.so.2 with build-id: 0414018caaea84ae28b5cac3374e2de68eaeecf8
                Found module libtbbmalloc.so.2 with build-id: ed5c024c117d607c4a753c0f263d60322571232b
                Found module libtbb.so.2 with build-id: e19254d0be6fc6d486d8ff3252922925d5d1dd93
                Found module libhdf5.so.103 with build-id: db9f5d317e0b2f95e9115f7525d441a1e59c594b
                Found module libhdf5_cpp.so.103 with build-id: f62176e6749ac02a5bfcae4505104f76bc9f7f42
                Found module libTKHLR.so.7 with build-id: b7026d5f43b93d5e97205c3377275b8e78146f2a
                Found module libTKBO.so.7 with build-id: 73dd798f7de93a7028479acac18d7fb7bfa2e9df
                Found module libTKPrim.so.7 with build-id: 33bd52c7520f0ef192f5eb2fe723bed9eb74c1ed
                Found module libTKShHealing.so.7 with build-id: cca40b008c763ae5e59fc3259e73212e13b58b96
                Found module libTKGeomAlgo.so.7 with build-id: cd09e1fb2ce1c5fec90957d14ff93372a7c50b0c
                Found module libTKGeomBase.so.7 with build-id: 661f188a75aa73c215f9ee86fd497cb6c3a90fbf
                Found module liblzma.so.5 with build-id: 8f6112440d7c7e991ffa27ef23ceb6bd6a6ed4a0
                Found module libz.so.1 with build-id: 5903f5c355c264403e4e7cdc66779584425ca3b8
                Found module libc.so.6 with build-id: 5d63c4327ba6cdd1e8b99eb1c0a9f056a98c67e1
                Found module libgcc_s.so.1 with build-id: 0028b8616fa79ea1496e4812c3fc9c7bf9607a56
                Found module libm.so.6 with build-id: 1586854d78f3048d2f112e36b97e6db246b60fa0
                Found module libstdc++.so.6 with build-id: 455be2588680c3ff57e3a7defe212a13e2efdbd1
                Found module libOpenCOLLADAStreamWriter.so.0.4 with build-id: 84bcd2bacfb2b2344f9c64a9f25ac1dc52e6d05e
                Found module libOpenCOLLADABaseUtils.so.0.4 with build-id: 8b53d194ef4f05c3411bb84308c32423eaf42c7b
                Found module libIfcParse.so.0.6 with build-id: 5e82201ef553ae3b8d16b3025d26c0648b59427b
                Found module libIfcGeom.so.0.6 with build-id: 9466b90c9cb444a612fb7577e04bd835a50b6155
                Found module libboost_program_options.so.1.76.0 with build-id: 465ffe68f6e5ab2c75c8b4248482d11e1e1e1446
                Found module libTKIGES.so.7 with build-id: 6ccc056660859b9fd6dcbde7fcb14c6d1c530fa6
                Found module libTKXSBase.so.7 with build-id: 97104cd7e0425094d0a9402065e85dea8d73f453
                Found module libTKSTEP.so.7 with build-id: 4c55919a222fe817c54a3fae697fe4b047c8affc
                Found module libTKMesh.so.7 with build-id: 8dbb10349ac743025a7efb73178f1b9428aeaa7a
                Found module libTKTopAlgo.so.7 with build-id: 3d8c88f49d69963cf0e8bd63570338b62112ef14
                Found module libTKG2d.so.7 with build-id: 5fba61eabe40936624b7da6645abd2663065973e
                Found module libTKG3d.so.7 with build-id: 7d854d164eedb96f95eed6af09986ec8ddf19017
                Found module libTKBRep.so.7 with build-id: 9f64089abecc56acacf275cfd981396f4e4c354e
                Found module libTKMath.so.7 with build-id: 232fcc30255baa9c2d2f33985d3eeb6bc620e844
                Found module libTKernel.so.7 with build-id: d2ebdcf07ab63b53eea18023a62cc8dc9cc72f2c
                Found module libSerializers.so.0.6 with build-id: aea81741623ba13f5239999592534ffe1210ffc2
                Found module libxml2.so.2 with build-id: 7f7c4a4c85206200336c641203ee60c41e6b7231
                Found module IfcConvert with build-id: 38751ba35b0feb3922a245728859821d0b78d72b
                Stack trace of thread 187314:
                #0  0x00007fc691f89f64 _ZN7IfcGeom10KernelIfc47convertEPKN4Ifc418IfcObjectPlacementER7gp_Trsf (libIfcGeom.so.0.6 + 0x2e1f64)
                #1  0x00007fc691f9a934 _ZN7IfcGeom27IteratorImplementation_Ifc410get_objectEi (libIfcGeom.so.0.6 + 0x2f2934)
                #2  0x00007fc691f94329 _ZN7IfcGeom27IteratorImplementation_Ifc43getEv (libIfcGeom.so.0.6 + 0x2ec329)
                #3  0x0000555cf7a868d1 main (IfcConvert + 0x448d1)
                #4  0x00007fc68b205560 __libc_start_call_main (libc.so.6 + 0x2d560)
                #5  0x00007fc68b20560c __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x2d60c)
                #6  0x0000555cf7a8a5b5 _start (IfcConvert + 0x485b5)

These are the dependencies I am using to build, all standard fedora packages:

cmake-3.22.2
gcc-c++-11.2.1
boost-1.76.0
libicu-69.1
openCOLLADA-1.6.68
pcre-8.45
python3-3.10.4
swig-4.0.2
libxml2-2.9.13
tbb-2020.3
blender-3.1.2
opencascade-7.5.0
hdf5-1.10.7
json-3.10.5
CGAL-5.3.1
gmp-6.2.0
mpfr-4.1.0

Build flags are:

-DENABLE_BUILD_OPTIMIZATIONS=ON -DCMAKE_CXX_FLAGS=-lxml2 -DBUILD_SHARED_LIBS=1 \
-DGLTF_SUPPORT=ON -DHDF5_SUPPORT=ON -DUSE_MMAP=ON
@aothms
Copy link
Member

aothms commented Apr 23, 2022

So the segfault is in

Frame 0: IfcGeom::KernelIfc4::convert(Ifc4::IfcObjectPlacement const*, gp_Trsf&)

Frame 1: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcgeom/IfcGeomIteratorImplementation.h#L973

Within the block specific to ELEMENT_HIERARCHY which is indeed specific to SVG

https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcconvert/IfcConvert.cpp#L815

I wouldn't be convinced that it's due to your build system. It might be something specific to the files you feed it. Or perhaps a compiler version tripping over some undefined behaviour.

@brunopostle
Copy link
Contributor Author

Thanks, I thought that I was seeing segfaults with other files, but actually IfcConvert is producing SVG files with and <style> sections but no other data. Is there one of the IFC files in the 0.7.0 sources that consistently produces SVG output that I can test with?

Attached is the IFC file from the stack trace above
simple.ifc.txt
.

@aothms
Copy link
Member

aothms commented Apr 23, 2022

The command line for SVG is also a bit magical perhaps, how do you precisely invoke IfcConvert?

@brunopostle
Copy link
Contributor Author

$ IfcConvert simple.ifc simple.svg --print-space-names --print-space-areas --exclude entities ifcspace
IfcOpenShell IfcConvert 0.7.0 (OCC 7.5.0)
Scanning file...
Done scanning file   
Parsing input file took 1 second
Creating geometry...
Segmentation fault (core dumped)

@aothms
Copy link
Member

aothms commented Apr 23, 2022

On Duplex.ifc [0] I get good results.

Duplex_A_20110907_optimized.ifc -yv d.svg --svg-project --door-arcs --print-space-names --print-space-areas --section-height-from-storeys --bound=1024x1024 --exclude entities IfcOpeningElement

afbeelding

[0] https://portal.nibs.org/files/wl/?id=O9inoVWDytV4P3UTS7iIdqhVKcTyVlcs

@aothms
Copy link
Member

aothms commented Apr 23, 2022

Ok, the issue was the aggregated wall

#36=IFCWALL('2q_0TfKbH59xaXpnEzTytx',$,'default/exterior',$,$,$,$,$,$);

The ELEMENT_HIERARCHY setting broke on the empty placement. The convention is that children of {aggregation, containment, voiding, filling, ...} have their object placement set relative to their host element.

It's a bit of a bug that we don't use a property maybe<> type yet for optional entity instances so instead of a catchable exception we end up with a nullptr dereference.

Should be fixed now in this particular case.

@brunopostle
Copy link
Contributor Author

Ok, that works fine here:
image

My generated IFC file with the same parameters segfaults:

$ IfcConvert simple.ifc -yv e.svg --svg-project --door-arcs --print-space-names --print-space-areas --section-height-from-storeys --bound=1024x1024 --exclude entities IfcOpeningElement
IfcOpenShell IfcConvert 0.7.0 (OCC 7.5.0)
Scanning file...
Done scanning file   
Parsing input file took 1 second
Creating geometry...
Segmentation fault (core dumped)

@brunopostle
Copy link
Contributor Author

Thanks, building now... will close when I confirm the fix

I had trouble using the API to set positions of aggregated objects, so I ended-up setting an absolute position, I'll investigate

@Moult
Copy link
Contributor

Moult commented Apr 23, 2022

@brunopostle what issues did you have? The API for edit_object_placement should auto handle relative placements: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.7.0/src/ifcopenshell-python/ifcopenshell/api/geometry/edit_object_placement.py#L77-L97

@brunopostle
Copy link
Contributor Author

@Moult I was creating an aggregate and assigning elements, but couldn't understand why geometry.edit_object_placement on the parent didn't move anything, so I ended up placing each child. I can see now that my problem is likely that the parent never had a placement in the first place. So the API is probably doing the best it can in the circumstances.

@Moult
Copy link
Contributor

Moult commented Apr 23, 2022

@brunopostle cheers, note that there is a should_transform_children setting there which allows you to toggle whether children should move when updating the placement of a parent.

@brunopostle
Copy link
Contributor Author

@Moult thanks, I can see I need to make a few changes.

Closing this bug, IfcConvert SVG output is working again after a rebuild:
image

brunopostle added a commit to brunopostle/homemaker-addon that referenced this issue Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants