[sketcher] crash on decreasing spline knot multiplicity

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!
User avatar
uwestoehr
Posts: 1951
Joined: Sun Jan 27, 2019 3:21 am

[sketcher] crash on decreasing spline knot multiplicity

Post by uwestoehr » Wed Oct 28, 2020 12:57 am

Decreasing the knot multiplicity leads to C++ exception from time to time. I found now a case where the issue is reproducible:
spline-c++-bug.FCStd
testfile
(11.33 KiB) Downloaded 14 times
I get the error this way:
XvQ6GCJ4sb.gif
screencast
XvQ6GCJ4sb.gif (407.24 KiB) Viewed 471 times

Can anybody confirm this?

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22869 (Git)
Build type: Release
Branch: master
Hash: 0f875168b67536fd859ed44e1fe50d9b0a11f223
Python version: 3.6.8
Qt version: 5.12.6
Coin version: 4.0.0a
OCC version: 7.4.0.beta
Locale: German/Germany (de_DE)
wmayer wrote: .
Last edited by uwestoehr on Sat Oct 31, 2020 2:48 am, edited 1 time in total.
wmayer
Site Admin
Posts: 16646
Joined: Thu Feb 19, 2009 10:32 am

Re: [sketcher] C++ exception on decreasing spline knot multiplicity

Post by wmayer » Fri Oct 30, 2020 9:19 am

What I get is this error message:
Unhandled unknown exception caught in GUIApplication::notify.
and it only appears in the output window. There is no dialog popping up.

This means an exception is raised somewhere but it's not a std::exception like in your case.
wmayer
Site Admin
Posts: 16646
Joined: Thu Feb 19, 2009 10:32 am

Re: [sketcher] C++ exception on decreasing spline knot multiplicity

Post by wmayer » Fri Oct 30, 2020 9:39 am

In my case the exception is thrown in:

Code: Select all

Geometry *GeomBSplineCurve::copy(void) const
{
    GeomBSplineCurve *newCurve = new GeomBSplineCurve(myCurve);
    newCurve->Construction = this->Construction;
    return newCurve;
}
it looks like something is wrong with myCurve.
wmayer
Site Admin
Posts: 16646
Joined: Thu Feb 19, 2009 10:32 am

Re: [sketcher] C++ exception on decreasing spline knot multiplicity

Post by wmayer » Fri Oct 30, 2020 12:14 pm

The reason for the exception is that the algorithm to decrease the multiplicity somewhere calculates the weight for a pole to be -0.5. This is of course wrong because the value must be > 0.
wmayer
Site Admin
Posts: 16646
Joined: Thu Feb 19, 2009 10:32 am

Re: [sketcher] C++ exception on decreasing spline knot multiplicity

Post by wmayer » Fri Oct 30, 2020 12:59 pm

So, it's an error in OCC. It produces an invalid B-spline but claims that decreasing the multiplicity was successful.

git commit 462efdab3 checks the weights of the poles and returns false if invalid.
User avatar
uwestoehr
Posts: 1951
Joined: Sun Jan 27, 2019 3:21 am

Re: [sketcher] C++ exception on decreasing spline knot multiplicity

Post by uwestoehr » Sat Oct 31, 2020 2:42 am

wmayer wrote:
Fri Oct 30, 2020 12:59 pm
git commit 462efdab3 checks the weights of the poles and returns false if invalid.
Many thanks for having a look! I get now a proper error dialog.

Nevertheless I see there a crash:
- take the testfile from initial post
- select the knot left to the one that triggered the C++ exception
- decrease its multiplicity

result: sometimes, but not always, it crashes either immediately or after about a second. Here is such a case:
nDvhWy5CXT.gif
screencast of crash
nDvhWy5CXT.gif (588.71 KiB) Viewed 313 times

In case you don't get a crash yet:
Method A:
- use the undo toolbar button
- select the next knot left to it
- decrease its multiplicity
Result: I get now in all cases an immediate crash

Method B:
- close the Sketch task dialog
- try to close FC by clicking the x button of its main window
result: it freezes and after a while Windows steps in reporting FC is not responding

Do you get this too?

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22891 (Git)
Build type: Release
Branch: master
Hash: 0a42189173b9d50a2849d9b2aa79c110a7565c89
Python version: 3.6.8
Qt version: 5.12.6
Coin version: 4.0.0a
OCC version: 7.4.0.beta
Locale: German/Germany (de_DE)
wmayer
Site Admin
Posts: 16646
Joined: Thu Feb 19, 2009 10:32 am

Re: [sketcher] crash on decreasing spline knot multiplicity

Post by wmayer » Sat Oct 31, 2020 6:57 am

Nevertheless I see there a crash:
When you run FreeCAD in the debugger where inside the code base (file and line) does it stop working?
wmayer
Site Admin
Posts: 16646
Joined: Thu Feb 19, 2009 10:32 am

Re: [sketcher] crash on decreasing spline knot multiplicity

Post by wmayer » Sat Oct 31, 2020 7:25 am

OK, I tried it a few times and I get crashes, too. However, each time the callstack looks quite different.

So, I tried it with an older build from July and there it crashes, too. Furthermore I tested with v0.18 and there it already crashes when decreasing the multiplicity.
User avatar
uwestoehr
Posts: 1951
Joined: Sun Jan 27, 2019 3:21 am

Re: [sketcher] crash on decreasing spline knot multiplicity

Post by uwestoehr » Sun Nov 01, 2020 3:17 am

wmayer wrote:
Sat Oct 31, 2020 6:57 am
Nevertheless I see there a crash:
When you run FreeCAD in the debugger where inside the code base (file and line) does it stop working?
You eventually triggered me to get a debug build running. And today I succeeded :D . However, I am confronted with a lot of exceptions and breakpoints so that I cannot yet get to the point where it crashes (I will report the exceptions in the developer forum).

Besides the crash, I see an issue with the new degree decrease feature you added last week. (I took a lesson and described the degree and multiplicity in the Wiki (Sketcher_BSplineIncreaseKnotMultiplicity and Sketcher_BSplineIncreaseDegree)
In https://wiki.freecadweb.org/Sketcher_BS ... escription you can see that the degree decrease is inconsistent beause instead of keeping the multiplicity, it increases it and moreover removes all knots by replacing them with a control point (compare third image with the second one). I think this is a bug because the knot multiplicity could be changed if necessary but they should not be removed. Or do I misunderstand the feature?
User avatar
uwestoehr
Posts: 1951
Joined: Sun Jan 27, 2019 3:21 am

Re: [sketcher] crash on decreasing spline knot multiplicity

Post by uwestoehr » Sun Nov 01, 2020 4:01 am

wmayer wrote:
Sat Oct 31, 2020 6:57 am
When you run FreeCAD in the debugger where inside the code base (file and line) does it stop working?
It is line 83 of \src\Gui\ViewProvider.cpp:

Code: Select all

for(;count>0;--count)
        group->removeChild(count-1);
The error message is:

Code: Select all

Exception thrown at 0x00007FFF0B633E49 in FreeCAD_d.exe: Microsoft C++ exception: Base::RuntimeError at memory location 0x0000007EE4AFFEF0.
Exception thrown at 0x00007FFF0B633E49 in FreeCAD_d.exe: Microsoft C++ exception: Base::RuntimeError at memory location 0x0000007EE4AFF920.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ExplorerFrame.dll'. 
Exception thrown at 0x00007FFF0B633E49 in FreeCAD_d.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x0000007EE4B02920.
Exception thrown at 0x00007FFF0B633E49 in FreeCAD_d.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x0000007EE4B02CD0.
'FreeCAD_d.exe' (Win32): Loaded 'D:\FreeCAD-build\bin\freetype.dll'. Module was built without symbols.
The thread 0x33d0 has exited with code 0 (0x0).
Critical error detected c0000374
Post Reply

Who is online

Users browsing this forum: Bance, FatihYAVAS, Grub, LBO, papyblaise and 32 guests