[FIXED] Using undo in Sketcher causes errors after the Big Merge

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!
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

[FIXED] Using undo in Sketcher causes errors after the Big Merge

Post by aapo »

Hi!

If I start FreeCAD v0.19 (after the Big Merge), and add a Part Design body, a sketch, and subsequently add anything adding constraints (e.g. two rectangles) into the sketch and undo the second one, there will be an error. All the constraints disappear, and I can't add any more constraints. When I subsequently exit Sketcher, and try to re-enter it I got complains about invalid sketch. Deleting constraints to external geometry makes the sketch re-editable again.


Sketcher-Error-01.png
Sketcher-Error-01.png (4.81 KiB) Viewed 2012 times

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17803 (Git)
Build type: Release
Branch: master
Hash: 89961a33d46063a43e9fb5b0308ca95d559eca94
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Last edited by aapo on Fri Aug 23, 2019 5:37 pm, edited 2 times in total.
chrisb
Veteran
Posts: 53951
Joined: Tue Mar 17, 2015 9:14 am

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by chrisb »

aapo wrote: Thu Aug 22, 2019 1:19 pm If I start FreeCAD v0.19 (after the Big Merge), and add a Part Design body, a sketch, and subsequently add anything adding constraints (e.g. two rectangles) into the sketch and undo the second one, there will be an error.
Can you provide a preferably very simple file with the rectangles and the references to external geometry?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by aapo »

chrisb wrote: Thu Aug 22, 2019 1:27 pm Can you provide a preferably very simple file with the rectangles and the references to external geometry?
Attached. Note that you'll be able to create such a file yourself simply by pressing "undo" in sketcher, with any sketch having any constraints. So, quite simple. I also tested with Linux with a self-compiled build, and the same error happens.

EDIT: I'm building the latest Git Master now to see, if there's a failure in the absolute newest FreeCAD head version.

EDIT2: It seems that the saved file does NOT have the bug, i.e. save-exit-load cycle fixes the corruption, which seems to exist in memory only as long as the executable runs.

OS: Debian GNU/Linux bullseye/sid (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17798 (Git)
Build type: Release
Branch: master
Hash: 7e60631239109c632a8f6cca83f6e7e5502e43a1
Python version: 2.7.16+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
Attachments
20190822-FreeCAD-error.FCStd
(5.74 KiB) Downloaded 59 times
Last edited by aapo on Thu Aug 22, 2019 3:46 pm, edited 1 time in total.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by Syres »

Firstly I can confirm the bug when the project file is in a changed state i.e. not saved. The Sketcher Validation Tool states Four Missing Coincidences and Invalid Constraints Found after Undoing the second Rectangle. But, if you Save and Close the project file and then re-open it the Sketch can be opened error free. Therefore my assumption is that the Sketch is being analysed and a false positive is being generated only when in this changed state.

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17803 (Git)
Build type: Release
Branch: master
Hash: 89961a33d46063a43e9fb5b0308ca95d559eca94
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by aapo »

The issue persists with the latest build, too. As an additional problem on Linux, FreeCAD crashes if I undo something in Sketcher, and after that add any constraint to the sketch.

Program received signal SIGSEGV, Segmentation fault.
#0 /lib/x86_64-linux-gnu/libc.so.6(+0x37840) [0x7f2d5c4a9840]
#1 0x7f2cf27e1d1a in finishDistanceConstraint(Gui::Command*, Sketcher::SketchObject*, bool)


So something in finishDistanceConstraint() seems to go belly up, presumably because the constraint list is in an unexpected state.

OS: Debian GNU/Linux bullseye/sid (KDE//usr/share/xsessions/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17850 (Git)
Build type: Release
Branch: master
Hash: 218d849355fa04f2a4790f17a7d0d0c193f99a03
Python version: 2.7.16+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
chrisb
Veteran
Posts: 53951
Joined: Tue Mar 17, 2015 9:14 am

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by chrisb »

Undo works flawless here:

loaded your file, opened Sketcher

Use case 1: drag right upper corner, undo, sketch returns to initial state, with

Use case 2: add another rectangle right above existing, undo, second rectangle vanishes

All undos were tested with keyboard and icon.

OS: macOS High Sierra (10.13)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17798 (Git)
Build type: Release
Branch: master
Hash: 7e60631239109c632a8f6cca83f6e7e5502e43a1
Python version: 3.7.3
Qt version: 5.9.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Germany (en_DE)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53951
Joined: Tue Mar 17, 2015 9:14 am

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by chrisb »

This may be related: After opening a file it is immediately in the edited state.

Edit: This is not a BigMerge issue, the behaviour was present before. I will investigate it further and open a new topic in due course.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
aapo
Posts: 615
Joined: Mon Oct 29, 2018 6:41 pm

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by aapo »

I made a gif animation demonstrating how to cause the error. I'm also quite sure that older v0.19 builds did not do this for me, as I use the undo feature quite often in Sketcher after I/O errors (idiot/operator :D). Anyway, builds after the Big Merge do this every time for me with both Linux and Windows, when I use undo to remove anything in Sketcher. I used https://github.com/FreeCAD/FreeCAD/releases v0.19 release build 17803 for Windows for making the gif animation.

EDIT: I also tested with the old build 17651 before the Big Merge, and Sketcher undo worked flawlessly there, no problems whatsoever. Even if it does not seem to be directly related to the Big Merge process, I must point out that the time of occurrence of the bug is quite suspicious.

20190823-Sketcher-bug-01.gif
20190823-Sketcher-bug-01.gif (974.58 KiB) Viewed 1907 times

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17803 (Git)
Build type: Release
Branch: master
Hash: 89961a33d46063a43e9fb5b0308ca95d559eca94
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: [Bug?] Using undo in Sketcher causes errors after the Big Merge

Post by Syres »

The only commit based purely based on description that I can see being the issue is https://github.com/FreeCAD/FreeCAD/commit/022e6c you'll notice that the constraints are removed from the first geometry as well as the actual undo the user wants to be achieved.

I can confirm the last build before the Link3 merge that I have does not have this bug:

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17651 (Git)
Build type: Release
Branch: master
Hash: 16c26cb3b1cd7209ea8efc8cb30b3b18fd80cf95
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United Kingdom (en_GB)
Post Reply