[BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
User avatar
Cyril
Posts: 83
Joined: Wed Aug 23, 2017 5:04 pm
Location: Geneva (Switzerland)
Contact:

[BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby Cyril » Sat Jan 11, 2020 5:24 pm

Hi,

I found an issue using Line.intersect / intersectCC. Same for LineSegment.
  • Steps to reproduce :
    1. Open FreeCAD
    2. Run following code in python console :

    Code: Select all

    import Part
    
    doc = FreeCAD.newDocument()
    v = FreeCAD.Vector
    w1 = Part.makePolygon([v(0,0,0), v(0,10,0), v(-5, 5, 0), v(0,0,0)])
    w2 = Part.makePolygon([v(0,2,0), v(0,8,0), v(5, 5, 0), v(0,2,0)])
    Part.show(w1)
    Part.show(w2)
    e1 = w1.Edges[0]
    e2 = w2.Edges[0]
    e1.Curve.intersectCC(e2.Curve)
    
  • Log : see attachment
  • Error message :

    Code: Select all

    Program received signal SIGSEGV, Segmentation fault.
    #0  /usr/lib/libc.so.6(+0x3bfb0) [0x7f1718865fb0]
    #1  0x7f168e3003a4 in Extrema_ExtCC::Points(int, Extrema_POnCurv&, Extrema_POnCurv&) const from /usr/lib/libTKGeomBase.so.7+0x54
    #2  0x7f168eae20d7 in GeomAPI_ExtremaCurveCurve::Points(int, gp_Pnt&, gp_Pnt&) const from /usr/lib/libTKGeomAlgo.so.7+0x57
    #3  0x7f1690dbe550 in Part::GeomCurve::intersect(opencascade::handle<Geom_Curve>, opencascade::handle<Geom_Curve>, std::vector<std::pair<Base::Vector3<double>, Base::Vector3<double> >, std::allocator<std::pair<Base::Vector3<double>, Base::Vector3<double> > > >&, double) from /usr/lib/freecad/lib/Part.so+0x3e0
    #4  0x7f1690dbeb2e in Part::GeomCurve::intersect(Part::GeomCurve*, std::vector<std::pair<Base::Vector3<double>, Base::Vector3<double> >, std::allocator<std::pair<Base::Vector3<double>, Base::Vector3<double> > > >&, double) const from /usr/lib/freecad/lib/Part.so+0xfe
    #5  0x7f1690cacfbe in Part::GeometryCurvePy::intersectCC(_object*) from /usr/lib/freecad/lib/Part.so+0x9e
    #6  0x7f1690cad1af in Part::GeometryCurvePy::staticCallback_intersectCC(_object*, _object*) from /usr/lib/freecad/lib/Part.so+0x1f
    #7  /usr/lib/libpython3.8.so.1.0(PyCFunction_Call+0xf3) [0x7f1719ffa5d3]
    #8  /usr/lib/libpython3.8.so.1.0(_PyObject_MakeTpCall+0x230) [0x7f1719fa3220]
    #9  /usr/lib/libpython3.8.so.1.0(_PyEval_EvalFrameDefault+0x4c9a) [0x7f171a00c97a]
    #10  /usr/lib/libpython3.8.so.1.0(_PyEval_EvalCodeWithName+0x2fa) [0x7f1719fd809a]
    #11  /usr/lib/libpython3.8.so.1.0(PyEval_EvalCodeEx+0x3a) [0x7f1719fd8cca]
    #12  /usr/lib/libpython3.8.so.1.0(PyEval_EvalCode+0x1c) [0x7f171a06473c]
    #13  0x7f171affbce6 in Gui::InteractiveInterpreter::runCode(PyCodeObject*) const from /usr/lib/freecad/lib/libFreeCADGui.so+0x66
    #14  0x7f171affc54c in Gui::InteractiveInterpreter::runSource(char const*) const from /usr/lib/freecad/lib/libFreeCADGui.so+0xac
    #15  0x7f171affc62d in Gui::InteractiveInterpreter::push(char const*) from /usr/lib/freecad/lib/libFreeCADGui.so+0xbd
    #16  0x7f171affc834 in Gui::PythonConsole::runSource(QString const&) from /usr/lib/freecad/lib/libFreeCADGui.so+0xf4
    #17  0x7f171affd107 in Gui::PythonConsole::runSourceFromMimeData(QString const&) from /usr/lib/freecad/lib/libFreeCADGui.so+0x737
    #18  0x7f171affeeac in Gui::PythonConsole::insertFromMimeData(QMimeData const*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x1cc
    #19  /usr/lib/libQt5Widgets.so.5(+0x356664) [0x7f1719b2d664]
    #20  0x7f1719b32a13 in QWidgetTextControl::processEvent(QEvent*, QMatrix const&, QWidget*) from /usr/lib/libQt5Widgets.so.5+0x193
    #21  0x7f1719b28b1c in QWidgetTextControl::processEvent(QEvent*, QPointF const&, QWidget*) from /usr/lib/libQt5Widgets.so.5+0x5c
    #22  0x7f1719b03aa4 in QPlainTextEdit::keyPressEvent(QKeyEvent*) from /usr/lib/libQt5Widgets.so.5+0x254
    #23  0x7f171b029653 in Gui::TextEdit::keyPressEvent(QKeyEvent*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x23
    #24  0x7f171affe097 in Gui::PythonConsole::keyPressEvent(QKeyEvent*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x277
    #25  0x7f1719976e1b in QWidget::event(QEvent*) from /usr/lib/libQt5Widgets.so.5+0x88b
    #26  0x7f1719a2822f in QFrame::event(QEvent*) from /usr/lib/libQt5Widgets.so.5+0x1f
    #27  0x7f1719a2af7a in QAbstractScrollArea::event(QEvent*) from /usr/lib/libQt5Widgets.so.5+0x26a
    #28  0x7f1719b032b9 in QPlainTextEdit::event(QEvent*) from /usr/lib/libQt5Widgets.so.5+0xc9
    #29  0x7f1719932472 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/libQt5Widgets.so.5+0x82
    #30  0x7f171993c3c4 in QApplication::notify(QObject*, QEvent*) from /usr/lib/libQt5Widgets.so.5+0xa74
    #31  0x7f171ae1f069 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x89
    #32  0x7f1718e99832 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/libQt5Core.so.5+0x182
    #33  /usr/lib/libQt5Widgets.so.5(+0x1bdf3e) [0x7f1719994f3e]
    #34  0x7f1719932472 in QApplicationPrivate::notify_helper(QObject*, QEvent*) from /usr/lib/libQt5Widgets.so.5+0x82
    #35  0x7f171993bc89 in QApplication::notify(QObject*, QEvent*) from /usr/lib/libQt5Widgets.so.5+0x339
    #36  0x7f171ae1f069 in Gui::GUIApplication::notify(QObject*, QEvent*) from /usr/lib/freecad/lib/libFreeCADGui.so+0x89
    #37  0x7f1718e99832 in QCoreApplication::notifyInternal2(QObject*, QEvent*) from /usr/lib/libQt5Core.so.5+0x182
    #38  0x7f171925e66d in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) from /usr/lib/libQt5Gui.so.5+0x16d
    #39  0x7f17192639ba in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) from /usr/lib/libQt5Gui.so.5+0x26a
    #40  0x7f171923cc2c in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/libQt5Gui.so.5+0xbc
    #41  /usr/lib/libQt5XcbQpa.so.5(+0x66a2c) [0x7f17133aba2c]
    #42  /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x27e) [0x7f17169d239e]
    #43  /usr/lib/libglib-2.0.so.0(+0x6c1b1) [0x7f17169d41b1]
    #44  /usr/lib/libglib-2.0.so.0(g_main_context_iteration+0x31) [0x7f17169d41f1]
    #45  0x7f1718ef1cc0 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/libQt5Core.so.5+0x60
    #46  0x7f1718e9839c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) from /usr/lib/libQt5Core.so.5+0x12c
    #47  0x7f1718ea03a6 in QCoreApplication::exec() from /usr/lib/libQt5Core.so.5+0x96
    #48  0x7f171ad93222 in Gui::Application::runApplication() from /usr/lib/freecad/lib/libFreeCADGui.so+0x15e2
    #49  freecad(main+0x759) [0x5562249605d9]
    #50  /usr/lib/libc.so.6(__libc_start_main+0xf3) [0x7f1718851153]
    #51  freecad(_start+0x2e) [0x5562249608fe]
    
  • FreeCAD infos :
    OS: Manjaro Linux (GNOME/gnome)
    Word size of OS: 64-bit
    Word size of FreeCAD: 64-bit
    Version: 0.19 (Git)
    Build type: Release
    Branch: master
    Hash: 49e4e45ff38b0459f0f9a76df634f6da4995b731
    Python version: 3.8.1
    Qt version: 5.14.0
    Coin version: 4.0.0a
    OCC version: 7.4.0
    Locale: French/Switzerland (fr_CH)
Attachments
FreeCAD.log
(17.85 KiB) Downloaded 6 times
I blog about HVAC / BIM / Energy : pythoncvc.net. If you like you can follow the RSS feed.
vocx
Posts: 2452
Joined: Thu Oct 18, 2018 9:18 pm

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby vocx » Sat Jan 11, 2020 10:14 pm

Cyril wrote:
Sat Jan 11, 2020 5:24 pm
Hi,

I found an issue using Line.intersect / intersectCC. Same for LineSegment.
  • Steps to reproduce :
This code does not produce a crash in my system.

Code: Select all

>>> import Part
>>> 
>>> doc = FreeCAD.newDocument()
>>> # App.setActiveDocument("Unnamed")
>>> # App.ActiveDocument=App.getDocument("Unnamed")
>>> # Gui.ActiveDocument=Gui.getDocument("Unnamed")
>>> v = FreeCAD.Vector
>>> w1 = Part.makePolygon([v(0,0,0), v(0,10,0), v(-5, 5, 0), v(0,0,0)])
>>> w2 = Part.makePolygon([v(0,2,0), v(0,8,0), v(5, 5, 0), v(0,2,0)])
>>> Part.show(w1)
>>> Part.show(w2)
>>> e1 = w1.Edges[0]
>>> e2 = w2.Edges[0]
>>> e1.Curve.intersectCC(e2.Curve)
[<Point (0,0,0) >]

Code: Select all

OS: Ubuntu 18.04.3 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19240 (Git)
Build type: Unknown
Branch: master
Hash: f97eb7026dfd59745829d4d8fb4831aa6354c099
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Your version is one commit older than my version.

You are trying to find the intersection of two co-linear edges (in the picture, it's where the two triangles meet). This would result in an infinite number of points; in my system it just returns the origin.
Colinear_intersections.png
Colinear_intersections.png (3.27 KiB) Viewed 360 times
To support the documentation effort, and code development, your donation is appreciated: paypal.
User avatar
Cyril
Posts: 83
Joined: Wed Aug 23, 2017 5:04 pm
Location: Geneva (Switzerland)
Contact:

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby Cyril » Sat Jan 11, 2020 11:08 pm

vocx wrote:
Sat Jan 11, 2020 10:14 pm
Your version is one commit older than my version.
Thanks for testing. Yes, wmayer did commit while I was writing my bug report ^^ but Iooked at the last commit content and I am almost 100% sure that it is absolutely not related.
vocx wrote:
Sat Jan 11, 2020 10:14 pm
You are trying to find the intersection of two co-linear edges (in the picture, it's where the two triangles meet). This would result in an infinite number of points; in my system it just returns the origin.
Yes I know. I was considering to use it in a loop handling the 3 cases. 1. I get an intersection. 2. I get no intersection. 3. I get (None or something like this) -> parallel or collinear. I am surprised that it returns Point(0,0,0) it might be confused with a real intersection at the origin. No ?
vocx wrote:
Sat Jan 11, 2020 10:14 pm
OCC version: 7.3.0
Maybe related to OCC 7.4 then ?
I blog about HVAC / BIM / Energy : pythoncvc.net. If you like you can follow the RSS feed.
User avatar
looo
Posts: 3031
Joined: Mon Nov 11, 2013 5:29 pm

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby looo » Sun Jan 12, 2020 6:49 pm

crashes with:

Code: Select all

OS: Ubuntu 18.04.3 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19242 (Git)
Build type: Release
Branch: master
Hash: 2d752745c298108a1d7ec756bd0ca57818c7a174
Python version: 3.7.6
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.4.0
Locale: German/Germany (de_DE)
works with:

Code: Select all

OS: Ubuntu 18.04.3 LTS (ubuntu:GNOME/ubuntu)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19066 (Git)
Build type: Release
Branch: master
Hash: c766d757912ded11d41bc825f82c47a8428396ad
Python version: 3.7.6
Qt version: 5.12.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
Seems like occt7.4 introduced a new bug. :evil:
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
Cyril
Posts: 83
Joined: Wed Aug 23, 2017 5:04 pm
Location: Geneva (Switzerland)
Contact:

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby Cyril » Mon Jan 13, 2020 1:51 pm

looo wrote:
Sun Jan 12, 2020 6:49 pm
Seems like occt7.4 introduced a new bug. :evil:
Thanks for testing.

I opened an issue on bug tracker : https://www.freecadweb.org/tracker/view.php?id=4247
I blog about HVAC / BIM / Energy : pythoncvc.net. If you like you can follow the RSS feed.
User avatar
looo
Posts: 3031
Joined: Mon Nov 11, 2013 5:29 pm

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby looo » Mon Jan 13, 2020 2:46 pm

It would be interesting to see what the diff between occt7.4 and occt7.3 for the function: GeomAPI_ExtremaCurveCurve::Points(int, gp_Pnt&, gp_Pnt&) looks like. There are several regression commits for occt but I didn't see one which is related to the problem reported here.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
User avatar
Kunda1
Posts: 6223
Joined: Thu Jan 05, 2017 9:03 pm

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby Kunda1 » Mon Jan 13, 2020 3:01 pm

looo wrote:
Mon Jan 13, 2020 2:46 pm
It would be interesting to see what the diff between occt7.4 and occt7.3 for the function: GeomAPI_ExtremaCurveCurve::Points(int, gp_Pnt&, gp_Pnt&) looks like. There are several regression commits for occt but I didn't see one which is related to the problem reported here.
Shouldn't this be possible using git blame ?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
looo
Posts: 3031
Joined: Mon Nov 11, 2013 5:29 pm

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby looo » Mon Jan 13, 2020 5:02 pm

Kunda1 wrote:
Mon Jan 13, 2020 3:01 pm
Shouldn't this be possible using git blame ?
My problem is that I have no accesss to the git repo of opencascade.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
minimalistic blog: https://looooo.github.io/mini-blog/
ickby
Posts: 2935
Joined: Wed Oct 05, 2011 7:36 am

Re: [BUG] Line.intersect / intersectCC between colinear line -> Segmentation fault

Postby ickby » Tue Jan 14, 2020 10:57 am

As it is a regression one could also report it on the occ bug tracker, usually those regressions are fixed by them.