[Fixed]Ticket #3921 - Crash when opening document with datum point intersecting line and plane

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!
reox
Posts: 867
Joined: Sat Aug 13, 2016 10:06 am
Contact:

[Fixed]Ticket #3921 - Crash when opening document with datum point intersecting line and plane

Postby reox » Mon Mar 25, 2019 7:28 am

I have created a document yesterday, which I'm not able to open. I get this error message:

Code: Select all

PositionBySupport: Geom_RectangularTrimmedSurface::U parameters out of range

Thread 1 "freecad-daily" received signal SIGSEGV, Segmentation fault.
0x00007fffde1cedc9 in Geom_RectangularTrimmedSurface::SetTrim(double, double, double, double, bool, bool, bool, bool) () from /usr/lib/x86_64-linux-gnu/libTKG3d.so.7

then a segfault with the following backtrace:

Code: Select all

#1 0x00007fffde1cedc9 in Geom_RectangularTrimmedSurface::SetTrim(double, double, double, double, bool, bool, bool, bool) () at /usr/lib/x86_64-linux-gnu/libTKG3d.so.7
[...]
#52215 0x00007fffde1cf010 in Geom_RectangularTrimmedSurface::SetTrim(double, double, double, double, bool, bool, bool, bool) () at /usr/lib/x86_64-linux-gnu/libTKG3d.so.7
#52216 0x00007fffde1cf635 in Geom_RectangularTrimmedSurface::Geom_RectangularTrimmedSurface(opencascade::handle<Geom_Surface> const&, double, double, double, double, bool, bool) () at /usr/lib/x86_64-linux-gnu/libTKG3d.so.7
#52217 0x00007fffdcb07b71 in  () at /usr/lib/x86_64-linux-gnu/libTKTopAlgo.so.7
#52218 0x00007fffdcb0ac5e in BRepExtrema_DistanceSS::Perform(TopoDS_Shape const&, TopoDS_Shape const&, Bnd_Box const&, Bnd_Box const&) () at /usr/lib/x86_64-linux-gnu/libTKTopAlgo.so.7
#52219 0x00007fffdcb154e0 in BRepExtrema_DistShapeShape::DistanceMapMap(NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> const&, NCollection_IndexedMap<TopoDS_Shape, TopTools_ShapeMapHasher> const&, NCollection_Sequence<Bnd_Box> const&, NCollection_Sequence<Bnd_Box> const&) () at /usr/lib/x86_64-linux-gnu/libTKTopAlgo.so.7
#52220 0x00007fffdcb17000 in BRepExtrema_DistShapeShape::Perform() () at /usr/lib/x86_64-linux-gnu/libTKTopAlgo.so.7
#52221 0x00007fffdcb182fc in BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(TopoDS_Shape const&, TopoDS_Shape const&, Extrema_ExtFlag, Extrema_ExtAlgo) () at /usr/lib/x86_64-linux-gnu/libTKTopAlgo.so.7
#52222 0x00007fffdeb7d02d in Attacher::AttachEnginePoint::calculateAttachedPlacement(Base::Placement) const () at /usr/lib/freecad-daily/lib/Part.so
#52223 0x00007fffdea868f9 in Part::AttachExtension::positionBySupport() () at /usr/lib/freecad-daily/lib/Part.so
#52224 0x00007fffdea86960 in Part::AttachExtension::onExtendedDocumentRestored() () at /usr/lib/freecad-daily/lib/Part.so
#52225 0x00007ffff6b66a2c in App::DocumentObject::onDocumentRestored() () at /usr/lib/freecad-daily/lib/libFreeCADApp.so
#52226 0x00007ffff6b32c6a in App::Document::restore() () at /usr/lib/freecad-daily/lib/libFreeCADApp.so
#52227 0x00007ffff6c24c39 in App::Application::openDocument(char const*) () at /usr/lib/freecad-daily/lib/libFreeCADApp.so
#52228 0x00007ffff6c39f2e in App::Application::sOpenDocument(_object*, _object*) () at /usr/lib/freecad-daily/lib/libFreeCADApp.so
#52229 0x00007ffff659cd49 in _PyMethodDef_RawFastCallKeywords () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52230 0x00007ffff659da85 in _PyCFunction_FastCallKeywords () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52231 0x00007ffff639f5f0 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52232 0x00007ffff64c6456 in _PyEval_EvalCodeWithName () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52233 0x00007ffff64c66de in PyEval_EvalCodeEx () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52234 0x00007ffff64c74ab in PyEval_EvalCode () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52235 0x00007ffff649525b in PyRun_StringFlags () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52236 0x00007ffff68f2cb6 in Base::InterpreterSingleton::runString[abi:cxx11](char const*) () at /usr/lib/freecad-daily/lib/libFreeCADBase.so
#52237 0x00007ffff6c3995b in App::Application::sLoadFile(_object*, _object*) () at /usr/lib/freecad-daily/lib/libFreeCADApp.so
#52238 0x00007ffff659cd49 in _PyMethodDef_RawFastCallKeywords () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52239 0x00007ffff659da85 in _PyCFunction_FastCallKeywords () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52240 0x00007ffff639f5f0 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52241 0x00007ffff64c6456 in _PyEval_EvalCodeWithName () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52242 0x00007ffff64c66de in PyEval_EvalCodeEx () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52243 0x00007ffff64c74ab in PyEval_EvalCode () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52244 0x00007ffff649525b in PyRun_StringFlags () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52245 0x00007ffff64cad9c in  () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52246 0x00007ffff659ccf5 in _PyMethodDef_RawFastCallKeywords () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52247 0x00007ffff659da85 in _PyCFunction_FastCallKeywords () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52248 0x00007ffff639fea9 in _PyEval_EvalFrameDefault () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52249 0x00007ffff64c6456 in _PyEval_EvalCodeWithName () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52250 0x00007ffff64c66de in PyEval_EvalCodeEx () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52251 0x00007ffff64c74ab in PyEval_EvalCode () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52252 0x00007ffff649525b in PyRun_StringFlags () at /usr/lib/x86_64-linux-gnu/libpython3.7m.so.1.0
#52253 0x00007ffff68f2cb6 in Base::InterpreterSingleton::runString[abi:cxx11](char const*) () at /usr/lib/freecad-daily/lib/libFreeCADBase.so
#52254 0x00007ffff7173a43 in Gui::Command::doCommand(Gui::Command::DoCmd_Type, char const*, ...) () at /usr/lib/freecad-daily/lib/libFreeCADGui.so
#52255 0x00007fffe52739ce in WebGui::BrowserView::onLinkClicked(QUrl const&) () at /usr/lib/freecad-daily/lib/WebGui.so
#52256 0x00007fffe5274248 in  () at /usr/lib/freecad-daily/lib/WebGui.so
#52257 0x00007ffff3e705c6 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52258 0x00007fffd77b7095 in QWebView::linkClicked(QUrl const&) () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52259 0x00007fffd77b7ec9 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52260 0x00007ffff3e705c6 in QMetaObject::activate(QObject*, int, int, void**) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52261 0x00007fffd77aced5 in QWebPage::linkClicked(QUrl const&) () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52262 0x00007fffd77ad81b in QWebPage::acceptNavigationRequest(QWebFrame*, QNetworkRequest const&, QWebPage::NavigationType) () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52263 0x00007fffd4f3e05c in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52264 0x00007fffd5ef9af3 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52265 0x00007fffd5ed9389 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52266 0x00007fffd5ed98b0 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52267 0x00007fffd5ed9ee8 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52268 0x00007fffd5eda9c8 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52269 0x00007fffd5edacba in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52270 0x00007fffd5edafe0 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52271 0x00007fffd5acddcb in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52272 0x00007fffd5bf4d01 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52273 0x00007fffd5bf2a2e in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52274 0x00007fffd5f78423 in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52275 0x00007fffd5f7c2cb in  () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52276 0x00007fffd4f65620 in QWebPageAdapter::mouseReleaseEvent(QMouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5
#52277 0x00007fffd77b55f9 in QWebPage::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52278 0x00007fffd77b6bc0 in QWebView::mouseDoubleClickEvent(QMouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52279 0x00007ffff47fd748 in QWidget::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52280 0x00007fffd77b818e in QWebView::event(QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5
#52281 0x00007ffff47bf491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52282 0x00007ffff47c6d08 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52283 0x00007ffff7149b38 in Gui::GUIApplication::notify(QObject*, QEvent*) () at /usr/lib/freecad-daily/lib/libFreeCADGui.so
#52284 0x00007ffff3e47479 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52285 0x00007ffff47c6019 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52286 0x00007ffff4818264 in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52287 0x00007ffff481adee in  () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52288 0x00007ffff47bf491 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52289 0x00007ffff47c6ac0 in QApplication::notify(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#52290 0x00007ffff7149b38 in Gui::GUIApplication::notify(QObject*, QEvent*) () at /usr/lib/freecad-daily/lib/libFreeCADGui.so
#52291 0x00007ffff3e47479 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52292 0x00007ffff41f2a6b in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#52293 0x00007ffff41f4925 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#52294 0x00007ffff41ced3b in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5
#52295 0x00007fffee2d88db in  () at /usr/lib/x86_64-linux-gnu/libQt5XcbQpa.so.5
#52296 0x00007ffff3e4614b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52297 0x00007ffff3e4e2b2 in QCoreApplication::exec() () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#52298 0x00007ffff70e737e in Gui::Application::runApplication() () at /usr/lib/freecad-daily/lib/libFreeCADGui.so
#52299 0x0000555555558776 in main ()
The first function is called 52k times in a recursion, I wonder why I get a segfault and not a stack overflow...

Anyways, I have the feeling this is caused by creating a poing on the intersection of a datum plane and a line.
I have this simple constelation: a cone where a plane is tangential to the cone surface and a line in the center of the cone.
2019-03-25-082211_926x369_scrot.png
2019-03-25-082211_926x369_scrot.png (31.11 KiB) Viewed 304 times
I want the point where both intersect, thus I created a point with the following properties:
2019-03-25-082322_884x312_scrot.png
2019-03-25-082322_884x312_scrot.png (34.44 KiB) Viewed 304 times
The point looks to be on the correct position, but as soon as I leave the dialog, the point has a exclamation mark added:
2019-03-25-082358_174x97_scrot.png
2019-03-25-082358_174x97_scrot.png (5.19 KiB) Viewed 304 times
I I try to edit the point, I get this message:
2019-03-25-082420_399x300_scrot.png
2019-03-25-082420_399x300_scrot.png (25.07 KiB) Viewed 304 times
When I ignore this and open the file again, I get the crash as above.

Code: Select all

OS: Debian GNU/Linux buster/sid
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16206 (Git)
Build type: Release
Branch: master
Hash: 763c2b22fed224eae1e767de1f7b8f2f703ba683
Python version: 3.7.3rc1
Qt version: 5.11.3
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Austria (de_AT)
Attachments
crash.FCStd
(7.41 KiB) Downloaded 7 times
Last edited by Kunda1 on Thu Jun 13, 2019 2:49 pm, edited 1 time in total.
kisolre
Posts: 2254
Joined: Wed Nov 21, 2018 1:13 pm

Re: Crash when opening document with datum point intersecting line and plane

Postby kisolre » Mon Mar 25, 2019 7:43 am

Same error but no crash under windows.

Code: Select all

OS: Windows 8.1
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Bulgarian/Bulgaria (bg_BG)
reox
Posts: 867
Joined: Sat Aug 13, 2016 10:06 am
Contact:

Re: Crash when opening document with datum point intersecting line and plane

Postby reox » Wed Mar 27, 2019 7:30 pm

So is this worth a bug report? Is it a bug or do I use it wrong?
wmayer
Site Admin
Posts: 15982
Joined: Thu Feb 19, 2009 10:32 am

Re: Crash when opening document with datum point intersecting line and plane

Postby wmayer » Thu Mar 28, 2019 11:19 am

reox wrote:
Wed Mar 27, 2019 7:30 pm
So is this worth a bug report? Is it a bug or do I use it wrong?
A crash is always a bug. The question is which code is the culprit, could be OCCT or FreeCAD code.
wmayer
Site Admin
Posts: 15982
Joined: Thu Feb 19, 2009 10:32 am

Re: Crash when opening document with datum point intersecting line and plane

Postby wmayer » Mon Apr 01, 2019 11:23 am

The first function is called 52k times in a recursion, I wonder why I get a segfault and not a stack overflow...
A stack overflow is more or less the same as a buffer overflow where a program writes into forbidden areas. Sooner or later this causes a segfault. See: https://en.wikipedia.org/wiki/Stack_buffer_overflow

With
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16342 (Git)
Build type: Debug
Branch: master
Hash: b7d263e601d7fb2537bba48afb34e270a165342e
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)

I only get the error:
PositionBySupport: Geom_RectangularTrimmedSurface::U1==U2
but the file seems to open fine. If you get a stack overflow then it's very likely an OCCT bug.
User avatar
Kunda1
Posts: 7548
Joined: Thu Jan 05, 2017 9:03 pm

Re: Ticket #3921 - Crash when opening document with datum point intersecting line and plane

Postby Kunda1 » Thu Jun 13, 2019 2:49 pm

Updated thread title with ticket number issue #3921
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
wmayer
Site Admin
Posts: 15982
Joined: Thu Feb 19, 2009 10:32 am

Re: Ticket #3921 - Crash when opening document with datum point intersecting line and plane

Postby wmayer » Thu Jun 13, 2019 7:30 pm

The problem seems to be that the datum line and datum plane are infinite. When trying to determine the distance of both shapes the class BRepExtrema_DistShapeShape (or better the internally used class BRepExtrema_DistanceSS) tries to project some points onto the surface which fails for all of them and thus the attempt to create a trimmed surface fails because start and end parameters are equal.

A minimum example to demonstrate the failure:

Code: Select all

p=Part.Plane()
p.Axis=App.Vector(-1,0,-1)
f=p.toShape()

l=Part.Line()
e=l.toShape()

f.distToShape(e)