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

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

Postby aapo » Thu Aug 22, 2019 1:19 pm

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 518 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
Posts: 19734
Joined: Tue Mar 17, 2015 9:14 am

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

Postby chrisb » Thu Aug 22, 2019 1:27 pm

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

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

Postby aapo » Thu Aug 22, 2019 2:56 pm

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 15 times
Last edited by aapo on Thu Aug 22, 2019 3:46 pm, edited 1 time in total.
Syres
Posts: 386
Joined: Thu Aug 09, 2018 11:14 am

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

Postby Syres » Thu Aug 22, 2019 3:35 pm

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: 93
Joined: Mon Oct 29, 2018 6:41 pm

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

Postby aapo » Thu Aug 22, 2019 3:37 pm

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
Posts: 5949
Joined: Thu Jan 05, 2017 9:03 pm

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

Postby Kunda1 » Thu Aug 22, 2019 4:26 pm

Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
chrisb
Posts: 19734
Joined: Tue Mar 17, 2015 9:14 am

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

Postby chrisb » Thu Aug 22, 2019 9:16 pm

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)
chrisb
Posts: 19734
Joined: Tue Mar 17, 2015 9:14 am

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

Postby chrisb » Thu Aug 22, 2019 9:40 pm

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

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

Postby aapo » Fri Aug 23, 2019 5:49 am

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 413 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
Posts: 386
Joined: Thu Aug 09, 2018 11:14 am

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

Postby Syres » Fri Aug 23, 2019 6:49 am

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)