Crash on loading old model

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Crash on loading old model

Post by edwilliams16 »

Crashes FreeCAD on open for me.

OS: macOS High Sierra (10.13)
Word size of FreeCAD: 64-bit
Version: 0.20.26498 (Git)
Build type: Release
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: C/Default (C)

Zipped crash dump enclosed. (Too long to post)
Attachments
crashdump.txt.zip
(34.56 KiB) Downloaded 18 times
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash on loading old model

Post by chrisb »

Thanks for the confirmations! Concerning OCC version: it works with this OCC 7.5.3, which crashes in the most recent.

OS: macOS 10.16
Word size of FreeCAD: 64-bit
Version: 0.20.26155 (Git)
Build type: Release
Branch: master
Hash: 0926a4148bcff11249fd4f56bc30256102ffe105
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: C/Default (C)
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash on loading old model

Post by chrisb »

I found more details where the crash occurs: When I remove the expression from the AttachmentOffset of PfadEnde-1, then the file loads. As soon as I add the expression again, FreeCAD crashes silently.

To be precise:
- open the attached file
- in the properties panel navigate to AttachmentOffset->Angle
- click on the f(x) symbol
- enter as expression without the final n: -<<Pfad1>>.AttachmentOffset.Rotatio
- as soon as the "n" is entered, FreeCAD crashes.
Attachments
crashAlmost.FCStd
(12.82 KiB) Downloaded 18 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: Crash on loading old model

Post by TheMarkster »

Rotation was recently added as a property of its own. Perhaps this is related.
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash on loading old model

Post by chrisb »

And here is a simplified use case with just two cubes. The scenario is similar:

- open the attached file
- select Cube001
- in the properties panel navigate to Placement ->Angle
- click on the f(x) symbol
- enter as expression without the final n: Cube.Placement.Rotatio
- as soon as the "n" is entered, FreeCAD crashes.
Attachments
crashCubes.FCStd
(4.65 KiB) Downloaded 20 times
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
edwilliams16
Veteran
Posts: 3106
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Crash on loading old model

Post by edwilliams16 »

FWIW

Code: Select all

 FreeCAD.getDocument('crashAlmost').getObject('Clone2D').AttachmentOffset.Rotation.Angle = FreeCAD.getDocument('crashAlmost').getObject('Sketch008').AttachmentOffset.Rotation.Angle
in the Python console works correctly.
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Crash on loading old model

Post by wmayer »

chrisb wrote: Sun Dec 05, 2021 2:52 pm I found more details where the crash occurs: When I remove the expression from the AttachmentOffset of PfadEnde-1, then the file loads. As soon as I add the expression again, FreeCAD crashes silently.
This fits to edwilliams16's findings. In his log file we get this call stack:
0 libsystem_c.dylib 0x00007fff702a7232 strlen + 18
1 libFreeCADApp.dylib 0x00000001057c065d App::ObjectIdentifier::access(App::ObjectIdentifier::ResolveResults const&, Py::Object*, std::__1::map<App::DocumentObject*, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<App::DocumentObject*>, std::__1::allocator<std::__1::pair<App::DocumentObject* const, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > >*) const::$_0::operator()(App::DocumentObject*, App::Property*, char const*) const + 637
2 libFreeCADApp.dylib 0x00000001057bc007 App::ObjectIdentifier::access(App::ObjectIdentifier::ResolveResults const&, Py::Object*, std::__1::map<App::DocumentObject*, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<App::DocumentObject*>, std::__1::allocator<std::__1::pair<App::DocumentObject* const, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > >*) const + 2823
3 libFreeCADApp.dylib 0x00000001057bb15f App::ObjectIdentifier::getDep(std::__1::map<App::DocumentObject*, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::less<App::DocumentObject*>, std::__1::allocator<std::__1::pair<App::DocumentObject* const, std::__1::set<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > > >&, bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*) const + 159
4 libFreeCADApp.dylib 0x00000001057bb09c App::ObjectIdentifier::getDep(bool, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*) const + 44
5 libFreeCADApp.dylib 0x0000000105737e9e App::Expression::getDeps(std::__1::map<App::DocumentObject*, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<App::ObjectIdentifier, std::__1::allocator<App::ObjectIdentifier> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<App::ObjectIdentifier, std::__1::allocator<App::ObjectIdentifier> > > > >, std::__1::less<App::DocumentObject*>, std::__1::allocator<std::__1::pair<App::DocumentObject* const, std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::vector<App::ObjectIdentifier, std::__1::allocator<App::ObjectIdentifier> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::vector<App::ObjectIdentifier, std::__1::allocator<App::ObjectIdentifier> > > > > > > >&, int) const + 286
6 libFreeCADApp.dylib 0x00000001057382fc App::Expression::getDeps(int) const + 44
7 libFreeCADApp.dylib 0x0000000105844527 App::PropertyExpressionEngine::buildGraphStructures(App::ObjectIdentifier const&, std::__1::shared_ptr<App::Expression>, boost::unordered::unordered_map<App::ObjectIdentifier, int, boost::hash<App::ObjectIdentifier>, std::__1::equal_to<App::ObjectIdentifier>, std::__1::allocator<std::__1::pair<App::ObjectIdentifier const, int> > >&, boost::unordered::unordered_map<int, App::ObjectIdentifier, boost::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<int const, App::ObjectIdentifier> > >&, std::__1::vector<std::__1::pair<int, int>, std::__1::allocator<std::__1::pair<int, int> > >&) const + 183
8 libFreeCADApp.dylib 0x000000010584662b App::PropertyExpressionEngine::buildGraph(boost::unordered::unordered_map<App::ObjectIdentifier const, App::PropertyExpressionEngine::ExpressionInfo, boost::hash<App::ObjectIdentifier const>, std::__1::equal_to<App::ObjectIdentifier const>, std::__1::allocator<std::__1::pair<App::ObjectIdentifier const, App::PropertyExpressionEngine::ExpressionInfo> > > const&, boost::unordered::unordered_map<int, App::ObjectIdentifier, boost::hash<int>, std::__1::equal_to<int>, std::__1::allocator<std::__1::pair<int const, App::ObjectIdentifier> > >&, boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, boost::no_property, boost::no_property, boost::listS>&, App::PropertyExpressionEngine::ExecuteOption) const + 507
9 libFreeCADApp.dylib 0x0000000105845c73 App::PropertyExpressionEngine::validateExpression(App::ObjectIdentifier const&, std::__1::shared_ptr<App::Expression const>) const + 1187
10 libFreeCADApp.dylib 0x00000001058450cf App::PropertyExpressionEngine::setValue(App::ObjectIdentifier const&, std::__1::shared_ptr<App::Expression>) + 223
11 libFreeCADApp.dylib 0x0000000105844dbb App::PropertyExpressionEngine::afterRestore() + 699
12 libFreeCADApp.dylib 0x0000000105632001 App::Document::afterRestore(std::__1::vector<App::DocumentObject*, std::__1::allocator<App::DocumentObject*> > const&, bool) + 465
13 libFreeCADApp.dylib 0x00000001056371d3 App::Document::afterRestore(bool) + 83
14 libFreeCADApp.dylib 0x000000010585b070 App::Application::openDocuments(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >*, bool) + 4560
15 libFreeCADApp.dylib 0x0000000105859dde App::Application::openDocument(char const*, bool) + 254
16 libFreeCADApp.dylib 0x000000010588eccf App::Application::sOpenDocument(_object*, _object*, _object*) + 271
17 libpython3.9.dylib 0x00000001052d1a34 cfunction_call + 52
18 libpython3.9.dylib 0x000000010526fac8 _PyObject_MakeTpCall + 136
19 libpython3.9.dylib 0x00000001053ad4a3 call_function + 323
20 libpython3.9.dylib 0x00000001053aaefc _PyEval_EvalFrameDefault + 44668
21 libpython3.9.dylib 0x000000010539e834 _PyEval_EvalCode + 548
22 libpython3.9.dylib 0x00000001054136f1 PyRun_StringFlags + 337
23 libFreeCADBase.dylib 0x0000000105b8edfb Base::InterpreterSingleton::runString(char const*) + 91
24 libFreeCADGui.dylib 0x0000000104261142 Gui::Command::_runCommand(char const*, int, Gui::Command::DoCmd_Type, char const*) + 162
25 libFreeCADGui.dylib 0x0000000104260f6d Gui::Command::_doCommand(char const*, int, Gui::Command::DoCmd_Type, char const*, ...) + 221
26 libFreeCADGui.dylib 0x000000010415e9d5 Gui::Application::open(char const*, char const*) + 1637
27 libFreeCADGui.dylib 0x00000001042706bf StdCmdOpen::activated(int) + 2175
28 libFreeCADGui.dylib 0x000000010425fd8b Gui::Command::_invoke(int, bool) + 635
29 libFreeCADGui.dylib 0x000000010425facc Gui::Command::invoke(int, Gui::Command::TriggerSource) + 364
30 libQt5Core.5.12.9.dylib 0x00000001066c4d64 QMetaObject::activate(QObject*, int, int, void**) + 1800


Inside ObjectIdentifier::access() the size of a std::string is checked (hence the call of strlen). So, somehow something must be wrong with the string but unfortunately nobody on Windows or Linux can confirm the crash. Even with my address-sanitizer build that checks for corrupted memory blocks I don't get a crash. So, at least it seems it's not directly related to the OCC version.
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Crash on loading old model

Post by chennes »

The problem is on the insertion of a null char * in the following code (ObjectIdentifier.cpp line 1686):

Code: Select all

        if(propset.size()!=1 || propset.begin()->size()) {
            if(!propName)
                propset.clear();
            propset.insert(propName);
        }
if propName is null here, the insertion into propset is failing: construction of a C++ std::string from a null pointer is undefined behavior. The standard requires that the pointer be to a null-terminated array of characters. I don't know what later code expects that to be: an empty string? In that case it's a pretty easy fix.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Crash on loading old model

Post by chennes »

Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
chrisb
Veteran
Posts: 53919
Joined: Tue Mar 17, 2015 9:14 am

Re: Crash on loading old model

Post by chrisb »

There was another model crashing my FreeCAD in the German forum: https://forum.freecadweb.org/viewtopic. ... 20#p553758. I didn't investigate it myself, but it should contain references to sketch dimensions. Hopefully the fix will be the same. :mrgreen:
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Post Reply