[Solved] FC Crashes after opening sketcher FC 0.20(Debug mode)

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
MikeLemon
Posts: 52
Joined: Mon Aug 09, 2021 7:13 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by MikeLemon »

chennes wrote: Sun Sep 12, 2021 8:24 pm The contents of the "Call Stack" portion of the Visual Studio window right after the program crashes. You should be able to Ctrl-A Ctrl-C and then paste it into a "code" block here.
That's that.

Code: Select all

 	ucrtbased.dll!00007fff9a137c75()	Unknown
 	ucrtbased.dll!00007fff9a137e13()	Unknown
 	ucrtbased.dll!00007fff9a14e01d()	Unknown
>	FreeCADGui_d.dll!messageHandler(QtMsgType type, const QMessageLogContext & context, const QString & msg) Line 1690	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::Workbench::setupCustomShortcuts() Line 326	C++
 	FreeCADGui_d.dll!Gui::Workbench::activate() Line 403	C++
 	FreeCADGui_d.dll!Gui::WorkbenchManager::activate(const std::string & name, const std::string & className) Line 132	C++
 	FreeCADGui_d.dll!Gui::Application::activateWorkbench(const char * name) Line 1356	C++
 	FreeCADGui_d.dll!Gui::Application::sActivateWorkbenchHandler(_object * __formal, _object * args) Line 865	C++
 	[External Code]	
 	FreeCADBase_d.dll!Base::InterpreterSingleton::runString(const char * sCmd) Line 252	C++
 	FreeCADGui_d.dll!Gui::Command::_runCommand(const char * file, int line, Gui::Command::DoCmd_Type eType, const char * sCmd) Line 683	C++
 	FreeCADGui_d.dll!Gui::Command::_runCommand(const char * file, int line, Gui::Command::DoCmd_Type eType, const QByteArray & sCmd) Line 694	C++
 	SketcherGui_d.pyd!SketcherGui::ViewProviderSketch::setEdit(int ModNum) Line 6379	C++
 	FreeCADGui_d.dll!Gui::ViewProvider::startEditing(int ModNum) Line 146	C++
 	FreeCADGui_d.dll!Gui::ViewProviderDragger::startEditing(int mode) Line 115	C++
 	FreeCADGui_d.dll!Gui::Document::setEdit(Gui::ViewProvider * p, int ModNum, const char * subname) Line 423	C++
 	FreeCADGui_d.dll!Gui::DocumentPy::setEdit(_object * args) Line 143	C++
 	FreeCADGui_d.dll!Gui::DocumentPy::staticCallback_setEdit(_object * self, _object * args) Line 455	C++
 	[External Code]	
 	FreeCADBase_d.dll!Base::InterpreterSingleton::runString(const char * sCmd) Line 252	C++
 	FreeCADGui_d.dll!Gui::Command::_runCommand(const char * file, int line, Gui::Command::DoCmd_Type eType, const char * sCmd) Line 683	C++
 	PartDesignGui_d.pyd!Gui::_cmdDocument<std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>>>(Gui::Command::DoCmd_Type cmdType, const App::Document * doc, const std::string & mod, std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>> && cmd) Line 85	C++
 	PartDesignGui_d.pyd!Gui::_cmdDocument<std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>>>(Gui::Command::DoCmd_Type cmdType, const App::DocumentObject * obj, const std::string & mod, std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>> && cmd) Line 143	C++
 	PartDesignGui_d.pyd!Gui::cmdGuiDocument<std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>>>(const App::DocumentObject * obj, std::basic_ostringstream<char,std::char_traits<char>,std::allocator<char>> && cmd) Line 162	C++
 	PartDesignGui_d.pyd!PartDesignGui::setEdit(App::DocumentObject * obj, PartDesign::Body * body) Line 90	C++
 	PartDesignGui_d.pyd!CmdPartDesignNewSketch::activated::__l93::<lambda>(const std::vector<App::DocumentObject *,std::allocator<App::DocumentObject *>> & features) Line 784	C++
 	PartDesignGui_d.pyd!boost::detail::function::void_function_obj_invoker1<void <lambda>(const std::vector<App::DocumentObject *,std::allocator<App::DocumentObject *>> &),void,std::vector<App::DocumentObject *,std::allocator<App::DocumentObject *>>>::invoke(boost::detail::function::function_buffer & function_obj_ptr, std::vector<App::DocumentObject *,std::allocator<App::DocumentObject *>> a0) Line 159	C++
 	PartDesignGui_d.pyd!boost::function1<void,std::vector<App::DocumentObject *,std::allocator<App::DocumentObject *>>>::operator()(std::vector<App::DocumentObject *,std::allocator<App::DocumentObject *>> a0) Line 768	C++
 	PartDesignGui_d.pyd!PartDesignGui::TaskDlgFeaturePick::~TaskDlgFeaturePick() Line 549	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::TaskView::TaskView::removeDialog() Line 666	C++
 	FreeCADGui_d.dll!Gui::TaskView::TaskView::accept() Line 801	C++
 	FreeCADGui_d.dll!Gui::TaskView::TaskView::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 371	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::GUIApplication::notify(QObject * receiver, QEvent * event) Line 87	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::GUIApplication::notify(QObject * receiver, QEvent * event) Line 87	C++
 	[External Code]	
 	FreeCADGui_d.dll!Gui::Application::runApplication() Line 2261	C++
 	FreeCAD_d.exe!main(int argc, char * * argv) Line 288	C++
 	FreeCAD_d.exe!WinMain(HINSTANCE__ * __formal, HINSTANCE__ * __formal, char * __formal, int __formal) Line 97	C++
 	[External Code]	
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by chennes »

Hmm, that's... exciting? Can you put a breakpoint on the line before the crash in Workbench.cpp (line 325) and see what it->second.c_str() is?
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by sgrogan »

I can't reproduce. Sketcher WB seems to work fine. I can start from VS or from the .exe


OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.25731 (Git)
Build type: Debug
Branch: master
Hash: e305dbd49caa2ede83dab8e8c34a4180b2cf26cc
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United States (en_US)
"fight the good fight"
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by sgrogan »

MikeLemon wrote: Mon Sep 13, 2021 6:13 am That's that.
Can you try with this Libpack? https://github.com/sgrogan/FreeCAD/releases/tag/libpack
The QT is slightly newer. Please use a new build directory,
"fight the good fight"
MikeLemon
Posts: 52
Joined: Mon Aug 09, 2021 7:13 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by MikeLemon »

sgrogan wrote: Thu Sep 16, 2021 11:05 pm
MikeLemon wrote: Mon Sep 13, 2021 6:13 am That's that.
Can you try with this Libpack? https://github.com/sgrogan/FreeCAD/releases/tag/libpack
The QT is slightly newer. Please use a new build directory,
Did that and the same error occurs.


Is there something related to running FC that I have to put in WINDOWS "PATH" maybe?

Completely unfamiliar with FC making it hard to debug the first debug compilation of the first build :|
MikeLemon
Posts: 52
Joined: Mon Aug 09, 2021 7:13 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by MikeLemon »

chennes wrote: Thu Sep 16, 2021 4:23 pm Hmm, that's... exciting? Can you put a breakpoint on the line before the crash in Workbench.cpp (line 325) and see what it->second.c_str() is?

if you mean the one in FreeCADGui

str = 0x000001652f0c22a0

after execution
User avatar
chennes
Veteran
Posts: 3904
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by chennes »

I'm looking at your backtrace, specifically:

Code: Select all

 	FreeCADGui_d.dll!Gui::Workbench::setupCustomShortcuts() Line 326	C++
The code around that point is:

Code: Select all

321        for (std::vector<std::pair<std::string,std::string> >::iterator it = items.begin(); it != items.end(); ++it) {
322            Command* cmd = cCmdMgr.getCommandByName(it->first.c_str());
323            if (cmd && cmd->getAction()) {
324                // may be UTF-8 encoded
325                QString str = QString::fromUtf8(it->second.c_str());
326                QKeySequence shortcut = str;
327                cmd->getAction()->setShortcut(shortcut.toString(QKeySequence::NativeText));
328                cmd->recreateTooltip(it->first.c_str(), cmd->getAction()); // The tooltip has the shortcut in it...
329            }
330        }
In your case the creation of QKeySequence is failing, so I want to see the actual contents of it->second, which is a std::string. Your debugger should let you peak into it and see what the actual string is that it's trying to create as a shortcut. It would be helpful also to see it->first, which should be the command the shortcut is set for.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
wmayer
Founder
Posts: 20298
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by wmayer »

When a program crashes then the cursor of the debugger doesn't necessarily point directly at the line that causes the crash. Very often the crash happened one line above. Since your call stack shows abort() as the top function you should set a break point inside messageHandler() after the QtFatalMsg.

My guess is that trying to assign a QString to a QKeySequence triggers a QtFatalMsg deep inside Qt code and in debug mode this will abort the application.

So, the point is to figure out what's wrong with the user defined shortcuts. Therefore it's probably best to get this part of your user.cfg. So, open your user.cfg in a text editor and search for the group "Shortcut" and copy the whole XML block and paste it here.
MikeLemon
Posts: 52
Joined: Mon Aug 09, 2021 7:13 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by MikeLemon »

wmayer wrote: Fri Sep 17, 2021 2:07 pm When a program crashes then the cursor of the debugger doesn't necessarily point directly at the line that causes the crash. Very often the crash happened one line above. Since your call stack shows abort() as the top function you should set a break point inside messageHandler() after the QtFatalMsg.

My guess is that trying to assign a QString to a QKeySequence triggers a QtFatalMsg deep inside Qt code and in debug mode this will abort the application.

So, the point is to figure out what's wrong with the user defined shortcuts. Therefore it's probably best to get this part of your user.cfg. So, open your user.cfg in a text editor and search for the group "Shortcut" and copy the whole XML block and paste it here.

Funny you said it I was playing with it earlier in the FC 0.19 version to evaluate FC workflow and it also transfers to this build so reseting all the short cuts all of a sudden works after days of cashing so THNAKS!

I guess I crossed some default FC shortcuts with the ones I created in the 0.19 version and that cause that confusion that crashed fc when entering this environment.


( BTW where exacly does free cad store the global FC default parameters? )
MikeLemon
Posts: 52
Joined: Mon Aug 09, 2021 7:13 pm

Re: FC Crashes after opening sketcher FC 0.20(Debug mode)

Post by MikeLemon »

chennes wrote: Fri Sep 17, 2021 1:38 pm I'm looking at your backtrace, specifically:

Code: Select all

 	FreeCADGui_d.dll!Gui::Workbench::setupCustomShortcuts() Line 326	C++
The code around that point is:

Code: Select all

321        for (std::vector<std::pair<std::string,std::string> >::iterator it = items.begin(); it != items.end(); ++it) {
322            Command* cmd = cCmdMgr.getCommandByName(it->first.c_str());
323            if (cmd && cmd->getAction()) {
324                // may be UTF-8 encoded
325                QString str = QString::fromUtf8(it->second.c_str());
326                QKeySequence shortcut = str;
327                cmd->getAction()->setShortcut(shortcut.toString(QKeySequence::NativeText));
328                cmd->recreateTooltip(it->first.c_str(), cmd->getAction()); // The tooltip has the shortcut in it...
329            }
330        }
In your case the creation of QKeySequence is failing, so I want to see the actual contents of it->second, which is a std::string. Your debugger should let you peak into it and see what the actual string is that it's trying to create as a shortcut. It would be helpful also to see it->first, which should be the command the shortcut is set for.
Thanks alot for the support overlapping shortcuts I made back in FC 0.19 interfered with sketched and cased it to crash.

Now back to coding!
Post Reply