Ticket #3435 - Crash with STEP export (bug in TopoDSToStep_MakeStepFace::Init:)

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
fhackenberger
Posts: 3
Joined: Tue Apr 24, 2018 10:28 am

Ticket #3435 - Crash with STEP export (bug in TopoDSToStep_MakeStepFace::Init:)

Post by fhackenberger »

Also a Bug report: issue #3435

Freecad crashes when exporting the (only) part in the attached project as a .step file.

OS: Ubuntu 16.04.4 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13515 (Git)
Build type: None
Branch: releases/FreeCAD-0-17
Hash: e17b340949b75a226cc7d89989b0aa238ccfc75f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedKingdom (en_GB)

I exported the part as an IGES, re-imported it and then everything is fine.

$ freecad --log-file -
FreeCAD 0.17, Libs: 0.17R13515 (Git)
© Juergen Riegel, Werner Mayer, Yorik van Havre 2001-2018
##### #### ### ####
# # # # # #
# ## #### #### # # # # #
#### # # # # # # # ##### # #
# # #### #### # # # # #
# # # # # # # # # ## ## ##
# # #### #### ### # # #### ## ## ##

Mod pluginloader InitGui.py starting ...
pluginmanager config file /home/fhackenberger/.FreeCAD//Mod/plugins/pluginloaderconfig.yaml
pluginmanager userconfig file /usr/lib/freecad/Mod/plugins/myconfig.yaml
userconfigfile not available
IOError: [Errno 2] No such file or directory: '/usr/lib/freecad/Mod/plugins/myconfig.yaml'

pluginmanager userconfig file /usr/lib/freecad/Mod/plugins/myconfig.yaml
userconfigfile not available and cannot be created
IOError: [Errno 2] No such file or directory: '/usr/lib/freecad/Mod/plugins/myconfig.yaml'

Mod pluginloader InitGui.py done
gentoolbars ...
My Macros done
My Workbenches done
Program received signal SIGSEGV, Segmentation fault.
#0 /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f190abe04b0]
#1 0x7f18e3ac65ff in TopoDSToStep_MakeStepFace::Init(TopoDS_Face const&, TopoDSToStep_Tool&, opencascade::handle<Transfer_FinderProcess> const&) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x1a7f
0000002 0x7f18e3ab8573 in TopoDSToStep_Builder::Init(TopoDS_Shape const&, TopoDSToStep_Tool&, opencascade::handle<Transfer_FinderProcess> const&) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x503
0000003 0x7f18e3ab8fe8 in TopoDSToStep_Builder::TopoDSToStep_Builder(TopoDS_Shape const&, TopoDSToStep_Tool&, opencascade::handle<Transfer_FinderProcess> const&) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x38
0000004 /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7(+0x260cfc) [0x7f18e3abecfc]
0000005 0x7f18e3abf60f in TopoDSToStep_MakeManifoldSolidBrep::TopoDSToStep_MakeManifoldSolidBrep(TopoDS_Solid const&, opencascade::handle<Transfer_FinderProcess> const&) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x5f
0000006 0x7f18e3adfe1c in STEPControl_ActorWrite::TransferShape(opencascade::handle<Transfer_Finder> const&, opencascade::handle<StepShape_ShapeDefinitionRepresentation> const&, opencascade::handle<Transfer_FinderProcess> const&, opencascade::handle<TopTools_HSequenceOfShape> const&, bool) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x1e7c
0000007 0x7f18e3ae5057 in STEPControl_ActorWrite::Transfer(opencascade::handle<Transfer_Finder> const&, opencascade::handle<Transfer_FinderProcess> const&) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x2e7
0000008 0x7f18e6406317 in Transfer_ActorOfFinderProcess::Transferring(opencascade::handle<Transfer_Finder> const&, opencascade::handle<Transfer_ProcessForFinder> const&) from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0x67
0000009 0x7f18e6411696 in Transfer_ProcessForFinder::TransferProduct(opencascade::handle<Transfer_Finder> const&) from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0xc6
0000010 0x7f18e641357c in Transfer_ProcessForFinder::Transferring(opencascade::handle<Transfer_Finder> const&) from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0x1cc
0000011 0x7f18e6413da6 in Transfer_ProcessForFinder::Transfer(opencascade::handle<Transfer_Finder> const&) from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0x26
0000012 /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7(+0x177c53) [0x7f18e6497c53]
0000013 0x7f18e6498758 in XSControl_Controller::TransferWriteShape(TopoDS_Shape const&, opencascade::handle<Transfer_FinderProcess> const&, opencascade::handle<Interface_InterfaceModel> const&, int) const from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0x78
0000014 0x7f18e3ae68b4 in STEPControl_Controller::TransferWriteShape(TopoDS_Shape const&, opencascade::handle<Transfer_FinderProcess> const&, opencascade::handle<Interface_InterfaceModel> const&, int) const from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0xc4
0000015 0x7f18e64b22fa in XSControl_TransferWriter::TransferWriteShape(opencascade::handle<Interface_InterfaceModel> const&, TopoDS_Shape const&) from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0x15a
0000016 0x7f18e64b9c0e in XSControl_WorkSession::TransferWriteShape(TopoDS_Shape const&, bool) from /usr/lib/x86_64-linux-gnu/libTKXSBase.so.7+0x3e
0000017 0x7f18e3aef501 in STEPControl_Writer::Transfer(TopoDS_Shape const&, STEPControl_StepModelType, bool) from /usr/lib/x86_64-linux-gnu/libTKSTEP.so.7+0x1c1
0000018 0x7f18c6386030 in STEPCAFControl_Writer::Transfer(STEPControl_Writer&, NCollection_Sequence<TDF_Label> const&, STEPControl_StepModelType, char const*, bool) from /usr/lib/x86_64-linux-gnu/libTKXDESTEP.so.7+0xa70
0000019 0x7f18c63867b6 in STEPCAFControl_Writer::Transfer(opencascade::handle<TDocStd_Document> const&, STEPControl_StepModelType, char const*) from /usr/lib/x86_64-linux-gnu/libTKXDESTEP.so.7+0xa6
0000020 0x7f18d8178c0a in ImportGui::Module::exporter(Py::Tuple const&) from /usr/lib/freecad/lib/ImportGui.so+0xdca
0000021 0x7f18d817209a in Py::ExtensionModule<ImportGui::Module>::invoke_method_varargs(void*, Py::Tuple const&) from /usr/lib/freecad/lib/ImportGui.so+0x3a
0000022 /usr/lib/freecad/lib/libFreeCADBase.so(method_varargs_call_handler+0x16c) [0x7f190ccfe62c]
0000023 /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalFrameEx+0x8a51) [0x7f190c7a6971]
0000024 /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCodeEx+0x85c) [0x7f190c8dc05c]
0000025 /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyEval_EvalCode+0x19) [0x7f190c79dda9]
0000026 /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyRun_StringFlags+0x76) [0x7f190c8181f6]
0000027 0x7f190cd2e916 in Base::InterpreterSingleton::runString[abi:cxx11](char const*) from /usr/lib/freecad/lib/libFreeCADBase.so+0x66
0000028 0x7f190d84c3fd in Gui::Command::runCommand(Gui::Command::DoCmd_Type, char const*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x4d
0000029 0x7f190d7dee96 in Gui::Application::exportTo(char const*, char const*, char const*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x3a6
0000030 0x7f190d857ef0 in StdCmdExport::activated(int) from /usr/lib/freecad/lib/libFreeCADGui.so+0x530
0000031 0x7f190d85063c in Gui::Command::invoke(int) from /usr/lib/freecad/lib/libFreeCADGui.so+0x7c
0000032 0x7f190b6ac010 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x4d0
0000033 0x7f190bbbed62 in QAction::triggered(bool) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x42
0000034 0x7f190bbc00b3 in QAction::activate(QAction::ActionEvent) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x83
0000035 /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x6219fd) [0x7f190c0219fd]
0000036 /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x625de9) [0x7f190c025de9]
0000037 0x7f190bc1b8d0 in QWidget::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x2a0
0000038 0x7f190c029ffb in QMenu::event(QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x6b
#39 0x7f190bbc4fdc in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x8c
#40 0x7f190bbcc0d6 in QApplication::notify(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x476
0000041 0x7f190d82b464 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x54
0000042 0x7f190b69790d in QCoreApplication::notifyInternal(QObject*, QEvent*) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x8d
0000043 0x7f190bbcb6dd in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x14d
0000044 /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x249d7c) [0x7f190bc49d7c]
0000045 0x7f190bc48c83 in QApplication::x11ProcessEvent(_XEvent*) from /usr/lib/x86_64-linux-gnu/libQtGui.so.4+0x16b3
0000046 /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x272542) [0x7f190bc72542]
0000047 /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x2a7) [0x7f1904300197]
0000048 /lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x4a3f0) [0x7f19043003f0]
0000049 /lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c) [0x7f190430049c]
0000050 0x7f190b6c82ae in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x7e
0000051 /usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x272616) [0x7f190bc72616]
0000052 0x7f190b69618f in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x3f
0000053 0x7f190b6964f5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x1b5
0000054 0x7f190b69c4b9 in QCoreApplication::exec() from /usr/lib/x86_64-linux-gnu/libQtCore.so.4+0x99
0000055 0x7f190d7e4240 in Gui::Application::runApplication() from /usr/lib/freecad/lib/libFreeCADGui.so+0x15b0
0000056 freecad(main+0x8b4) [0x403804]
0000057 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7f190abcb830]
0000058 freecad(_start+0x29) [0x404a49]
Attachments
crash-step-export.fcstd
(34.17 KiB) Downloaded 54 times
Last edited by Kunda1 on Mon Jun 17, 2019 7:47 am, edited 1 time in total.
Reason: Updated thread title with ticket and bug issue
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Crash with STEP export

Post by easyw-fc »

fhackenberger wrote: Tue Apr 24, 2018 10:32 am Also a Bug report: https://www.freecadweb.org/tracker/view.php?id=3435

Freecad crashes when exporting the (only) part in the attached project as a .step file.

OS: Ubuntu 16.04.4 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13515 (Git)
Build type: None
Branch: releases/FreeCAD-0-17
Hash: e17b340949b75a226cc7d89989b0aa238ccfc75f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedKingdom (en_GB)

I exported the part as an IGES, re-imported it and then everything is fine.

$ freecad --log-file -
FreeCAD 0.17, Libs: 0.17R13515 (Git)
no issue here with

OS: Ubuntu 16.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.13515 (Git)
Build type: None
Branch: releases/FreeCAD-0-17
Hash: e17b340949b75a226cc7d89989b0aa238ccfc75f
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)

or
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13554 (Git)
Build type: Release
Branch: master
Hash: 6ac274b081736ea8867b4856d3bda9a210b83876
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
fhackenberger
Posts: 3
Joined: Tue Apr 24, 2018 10:28 am

Re: Crash with STEP export

Post by fhackenberger »

Just for clarification:
  • Open the attached file
  • Double-click on the part
  • Select File->Export...
  • Files of type: STEP with colors (*.step *.stp)
  • Type in a filename (crash)
  • Click Save
  • FreeCAD crashes
The only difference I could find to your version is the locale, but even starting FreeCAD with LANG=en_US.UTF-8 leads to the same crash.

What else can I try to help you to reproduce the crash?
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Crash with STEP export

Post by easyw-fc »

I'm sorry I couldn't find any hint to help.
May be someone using Ubuntu more often than me could help...
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Crash with STEP export

Post by bejant »

Is the object in the FreeCAD file already a .step object?
I get a crash using the revised steps listed below:
fhackenberger wrote: Tue Apr 24, 2018 4:46 pm Just for clarification:
  • Open the attached file
  • Double-click Single-click on the part
  • Select File->Export...
  • Files of type: STEP with colors (*.step *.stp)
  • Type in a filename
  • Click the Save button ==> (crash)
(I don't have a debug build so I can't do a backtrace)

OS: Ubuntu 16.04.4 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.17.13519 (Git)
Build type: None
Branch: releases/FreeCAD-0-17
Hash: 1a8b868018f45ea486c0023fdbfeb06febc1fb89
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)

OS: Ubuntu 16.04.4 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.18.13588 (Git)
Build type: None
Branch: master
Hash: 1e2b9758cc7f6872da018ee71983a82499866508
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0
Locale: English/UnitedStates (en_US)
fhackenberger
Posts: 3
Joined: Tue Apr 24, 2018 10:28 am

Re: Crash with STEP export

Post by fhackenberger »

The object in the freecad file was imported from a STEP file, so I guess yes, it's probably a STEP object. Although I don't really know what that entails.
wmayer
Founder
Posts: 20317
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Crash with STEP export

Post by wmayer »

Just for clarification:
When reading in a STEP file then the CAD kernel OCCT converts the data into a BRep model and from there on it doesn't make much sense to call it a STEP object because any relation to the STEP file is lost.

The problem must be that either some geometry or tolerances or so in the STEP file is broken which leads to a corrupted BRep model and thus a later export in STEP causes the crash or there is a bug in OCCT in the import or export routine.

When I test the file with the version below then on export to STEP with colors it doesn't do anything, i.e. it doesn't create a file. When I use the simplified STEP export (Part workbench > Part > Export) then a Python exception is raised:
Exception (Wed Apr 25 10:36:45 2018): Error in transferring STEP
Traceback (most recent call last):
File "<string>", line 4, in <module>
<type 'exceptions.RuntimeError'>: FreeCAD exception thrown (Error in transferring STEP)

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.13586 (Git)
Build type: Release
Branch: master
Hash: a099eb3caf10b7ef03ffb3c7d4a94ece0fbfcce5
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Locale: German/Germany (de_DE)
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Crash with STEP export

Post by easyw-fc »

wmayer wrote: Wed Apr 25, 2018 8:49 am The problem must be that either some geometry or tolerances or so in the STEP file is broken which leads to a corrupted BRep model and thus a later export in STEP causes the crash or there is a bug in OCCT in the import or export routine.

When I test the file with the version below then on export to STEP with colors it doesn't do anything, i.e. it doesn't create a file. When I use the simplified STEP export (Part workbench > Part > Export) then a Python exception is raised:
Exception (Wed Apr 25 10:36:45 2018): Error in transferring STEP
Traceback (most recent call last):
File "<string>", line 4, in <module>
<type 'exceptions.RuntimeError'>: FreeCAD exception thrown (Error in transferring STEP)
I found it!
I cannot replicate the errors if the exporter has p-curves disabled......

I can export both with STEP with colors and with Part CAD export...
I'm attaching the files without p-curves...
crash-step-export.step
(211.63 KiB) Downloaded 34 times
exported from File export
crash-step-export.stp
(198.41 KiB) Downloaded 38 times
exported from Part CAD export


p-curves are sort of 'abandoned' by OCC (file size bigger and troubles with sw compatibility with proprietary cads)
https://tracker.dev.opencascade.org/view.php?id=25654
Summary 0025654: Disable writing pcurves to STEP and IGES by default
Description Currently global DE parameter write.surfacecurve.mode is set to 1 by default, i.e. pcurves are stored in the file when it is written to STEP and IGES.
Theoretically this should improve quality of translation and make import faster. However in practice it seems to be not the case. For instance, problem reported in #25523 disappears if pcurves are not written. On that model, writing without pcurves reduces size of the file 3 times, eliminates problems of loading that file to Hoops Exchange Demo, and improves loading to Pro Engineer.
On some other models from customers we also observe considerable difference in size of STEP file written with pcurves vs. one without it (3.6 Mb vs. 17 Mb), with no visible effect on performance of import.
Hence it will be logical to change default value of write.surfacecurve.mode to 0.
disable-pcurves.png
disable-pcurves.png (30.51 KiB) Viewed 2963 times
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Crash with STEP export

Post by bejant »

wmayer wrote: Wed Apr 25, 2018 8:49 am Just for clarification:
When reading in a STEP file then the CAD kernel OCCT converts the data into a BRep model and from there on it doesn't make much sense to call it a STEP object because any relation to the STEP file is lost.
Thank you for the explanation - it's good to know what happens internally without trying to decipher the code.
easyw-fc wrote: Wed Apr 25, 2018 9:42 am
Hence it will be logical to change default value of write.surfacecurve.mode to 0.
Thanks for finding that. I un-ticked it in my Preferences.
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Crash with STEP export

Post by NormandC »

wmayer wrote: Wed Apr 25, 2018 8:49 am When reading in a STEP file then the CAD kernel OCCT converts the data into a BRep model and from there on it doesn't make much sense to call it a STEP object because any relation to the STEP file is lost.
While BREP (*.brp, *.brep) is the native format of Open Cascade, it can also refer to Boundary reprentation, a type of 3D modeling representation that is shared by most CAD programs (with the notable exception of BRL-CAD and OpenSCAD). Open Cascade is a B-rep geometric modeling kernel, as are Parasolid, ACIS, CGM, Granite, etc.

I've always thought that a STEP model was a B-rep model as well. Are you saying that's not the case, that it's the import process that converts it into a B-rep (generic term) model?
Post Reply