Sketcher: Possible crash when closing application after creating a sketch #13622
Closed
2 tasks done
Labels
Bug
This issue or PR is related to a bug
Crash
For issues describing crashes or PRs fixing one
Regression
Bugs describing a regression or PRs fixing one
WB Sketcher
Related to the Sketcher Workbench
Is there an existing issue for this?
Problem description
Steps to reproduce:
The crash won't be notified in the vast majority of cases but nevertheless the bug is there. The crash may only be observed when building FreeCAD with the address sanitizer option.
The problem is introduced with this commit 89bf7f3
The change adds the new class CurveConverter that attaches itself to a parameter group and in its destructor it detaches itself again.
Now the problem is that a static instance is created in DrawSketchHandler::drawEdit. The point with static objects is that they will be freed after the main() function has been exited. So, at this point the Application object has been deleted.
Now the attempt to access the parameter manger inside the destructor of CurveConverter is already undefined behaviour.
Full version info
Subproject(s) affected?
Sketcher
Anything else?
When looking at the code base then the only instance of CurveConverter is inside DrawSketchHandler::drawEdit. So, a fix for the problem is very easy: remove the code inside the destructor and add maybe a comment.
Code of Conduct
The text was updated successfully, but these errors were encountered: