Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sketcher: Possible crash when closing application after creating a sketch #13622

Closed
2 tasks done
wwmayer opened this issue Apr 24, 2024 · 1 comment · Fixed by #13625
Closed
2 tasks done

Sketcher: Possible crash when closing application after creating a sketch #13622

wwmayer opened this issue Apr 24, 2024 · 1 comment · Fixed by #13625
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

Comments

@wwmayer
Copy link
Contributor

wwmayer commented Apr 24, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

Steps to reproduce:

  1. Create sketch
  2. Draw any curve element
  3. Close sketcher and document
  4. Exit application
  5. Crash

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

OS: Ubuntu 22.04.4 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.36963 +6 (Git)
Build type: debug
Branch: fix_new_start_page
Hash: 54f6d0083328641ac7d5a85697c5851759ccddb1
Python 3.10.12, Qt 5.15.3, Coin 4.0.0, Vtk 7.1.1, OCC 7.5.1
Locale: German/Germany (de_DE)

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

  • I agree to follow this project's Code of Conduct
@luzpaz luzpaz added Bug This issue or PR is related to a bug WB Sketcher Related to the Sketcher Workbench Crash For issues describing crashes or PRs fixing one Regression Bugs describing a regression or PRs fixing one labels Apr 24, 2024
wwmayer added a commit to wwmayer/FreeCAD that referenced this issue Apr 24, 2024
Accessing the parameter manager inside ~CurveConverter() is undefined behaviour because it will be accessed after the main() function
has been exited.

Fixes FreeCAD#13622
@wwmayer
Copy link
Contributor Author

wwmayer commented Apr 24, 2024

#13625

chennes pushed a commit that referenced this issue Apr 29, 2024
Accessing the parameter manager inside ~CurveConverter() is undefined behaviour because it will be accessed after the main() function
has been exited.

Fixes #13622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants