[Sketcher] Crash in "Convert to NURBS"

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

[Sketcher] Crash in "Convert to NURBS"

Post by jnxd »

Steps to reproduce:
1. Open the attached file.
2. Press and drag the cursor over the edges to select at least one arc of the slot and its end points (NOTE: selecting these by individually clicking on them does not reproduce the bug). [EDIT: reworded the step for clarification]
3. Click "Convert to NURBS" (for some reason called BSplineApproximate). The conversion does happen.
4. Close the sketch. Crash!

Tested with version (Note that the one new commit here does not change the main method, but I will update with latest master once compiled EDIT: Confirmed with master):

Code: Select all

OS: Manjaro Linux (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.20.27664 (Git)
Build type: Release
Branch: master
Hash: e81eea9bb48af59db92230bbb99f6fbdfef72be8
Python 3.10.2, Qt 5.15.2, Coin 4.0.1, OCC 7.5.3
Locale: English/United States (en_US)
Attachments
pr-6403.FCStd
(4.65 KiB) Downloaded 53 times
Last edited by jnxd on Sun Feb 20, 2022 11:08 pm, edited 3 times in total.
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: [Sketcher] Crash in "Convert to NURBS"

Post by kisolre »

There is no "Convert to NURBS" in Sketch editing mode. There is "Convert to B-spline" which works as expected here:

Code: Select all

OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of FreeCAD: 64-bit
Version: 0.20.27664 (Git)
Build type: Release
Branch: master
Hash: e81eea9bb48af59db92230bbb99f6fbdfef72be8
Python 3.8.8, Qt 5.15.2, Coin 4.0.1, OCC 7.5.3
Locale: Bulgarian/Bulgaria (bg_BG)
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Sketcher] Crash in "Convert to NURBS"

Post by jnxd »

kisolre wrote: Sun Feb 20, 2022 7:11 pm There is no "Convert to NURBS" in Sketch editing mode. There is "Convert to B-spline" which works as expected here:

Code: Select all

OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of FreeCAD: 64-bit
Version: 0.20.27664 (Git)
Build type: Release
Branch: master
Hash: e81eea9bb48af59db92230bbb99f6fbdfef72be8
Python 3.8.8, Qt 5.15.2, Coin 4.0.1, OCC 7.5.3
Locale: Bulgarian/Bulgaria (bg_BG)
That is what I meant: https://wiki.freecadweb.org/Sketcher_BSplineApproximate. The command is called "convert to nurbs" so I should probably put a link or clarify the wording. Can you confirm you selected multiple edges by pressing left click and dragging the mouse over the edges?
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: [Sketcher] Crash in "Convert to NURBS"

Post by kisolre »

You continue mentioning NURBS:
.
NoNURBS.JPG
NoNURBS.JPG (59.35 KiB) Viewed 1796 times
.
I made a LeftToRight drag select which selects only completely encased entities. I selected the right slot arc, its vertices and its center.
Now I made RightToLeft select over the whole rightmost arc which selects all touched entities. The arc, its endpoints and center, the slot side edges and the vertices connecting them to the arcs were selected. Still no problem converting and exiting sketch edit mode.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Sketcher] Crash in "Convert to NURBS"

Post by jnxd »

kisolre wrote: Sun Feb 20, 2022 7:45 pm You continue mentioning NURBS:
.
NoNURBS.JPG
.
Sorry for the confusion. I was on editing on phone when I edited the post after your first comment so only did minimal changes.

I am referring to https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L412. Note how the command is called CmdSketcherConvertToNURB (it should be NURBS), but the BSplineApproximate name also exists. The underlying Part command also converts it to a NURBS rather than a "simple" B-Spline. In fact, we need NURBS to exactly represent a circle, or a general conic. This discussion also came up in a PR I am working on: https://github.com/FreeCAD/FreeCAD/pull ... 1046234909.
I made a LeftToRight drag select which selects only completely encased entities. I selected the right slot arc, its vertices and its center.
Now I made RightToLeft select over the whole rightmost arc which selects all touched entities. The arc, its endpoints and center, the slot side edges and the vertices connecting them to the arcs were selected. Still no problem converting and exiting sketch edit mode.
Thanks for the detailed test. That should give us some more idea what might be happening. This boils the search space down to platform or python version.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Sketcher] Crash in "Convert to NURBS"

Post by jnxd »

For context this is what is happening:
sketcher-cv-to-spline-issue.gif
sketcher-cv-to-spline-issue.gif (725.24 KiB) Viewed 1714 times
The output on console is as follows:

Code: Select all

munmap_chunk(): invalid pointer
zsh: abort (core dumped)  bin/FreeCAD
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: [Sketcher] Crash in "Convert to NURBS"

Post by kisolre »

jnxd wrote: Sun Feb 20, 2022 11:47 pm For context this is what is happening:
And it is also happening here. But that is not what you described in the OP ;)
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Sketcher] Crash in "Convert to NURBS"

Post by jnxd »

kisolre wrote: Mon Feb 21, 2022 11:29 am
jnxd wrote: Sun Feb 20, 2022 11:47 pm For context this is what is happening:
And it is also happening here. But that is not what you described in the OP ;)
OK now I'm cpnfused how you interpreted it. By your description it doesn't appear to be any different from what I showed...
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: [Sketcher] Crash in "Convert to NURBS"

Post by kisolre »

jnxd wrote: Mon Feb 21, 2022 11:41 am By your description it doesn't appear to be any different from what I showed...
Selecting right arc and its vertices - Ok.
Selecting left arc and its vertices - crash.
Your OP - select at least one(ANY) slot arc.
User avatar
jnxd
Posts: 952
Joined: Mon Mar 30, 2015 2:30 pm
Contact:

Re: [Sketcher] Crash in "Convert to NURBS"

Post by jnxd »

kisolre wrote: Mon Feb 21, 2022 12:30 pm
jnxd wrote: Mon Feb 21, 2022 11:41 am By your description it doesn't appear to be any different from what I showed...
Selecting right arc and its vertices - Ok.
Selecting left arc and its vertices - crash.
Your OP - select at least one(ANY) slot arc.
You know what? I'm not even mad. I'm glad I didn't describe it well enough or I'd never have learned there's no crash for the right side.
Post Reply