Debug build of FreeCAD crashes on startup (TabBar, fcgear and some other addons involved)

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!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Debug build of FreeCAD crashes on startup (TabBar, fcgear and some other addons involved)

Post by DeepSOIC »

Hi!
I'm recently having trouble running debug build of FreeCAD, because it crashes on start-up with this printed to terminal (in Qt creator):

Code: Select all

Starting T:\_vt\dev\PC\Qt\FreeCAD\build-debug\bin\FreeCAD_d.exe...
Fatal Python error: PyThreadState_Get: no current thread
Fatal Python error: PyThreadState_Get: no current thread
The program has unexpectedly finished.
T:\_vt\dev\PC\Qt\FreeCAD\build-debug\bin\FreeCAD_d.exe crashed
The problem happens in activateWorkbench:

Code: Select all

0	DebugBreak	KERNELBASE		0x7fff7e946142	
1	Py_FatalError	pythonrun.c	1701	0x1e27688d	
2	PyThreadState_Get	pystate.c	332	0x1e254fca	
3	PyObject_RichCompare	object.c	949	0x1e180568	
4	PyObject_RichCompareBool	object.c	1004	0x1e1807c4	
5	lookdict	dictobject.c	342	0x1e14125c	
6	PyDict_GetItem	dictobject.c	743	0x1e13dc86	
7	PyDict_GetItemString	dictobject.c	2425	0x1e13dceb	
8	Gui::Application::activateWorkbench	Application.cpp	936	0x7fff454671d5	
9	Gui::Application::runApplication	Application.cpp	1724	0x7fff4546be45	
10	main	MainGui.cpp	239	0x7ff6b1a435c5	
11	WinMain	FreeCAD_d		0x7ff6b1a532d1	
12	__tmainCRTStartup	crtexe.c	618	0x7ff6b1a51391	
13	WinMainCRTStartup	crtexe.c	466	0x7ff6b1a5110e	
14	BaseThreadInitThunk	KERNEL32		0x7fff81d48364	
15	RtlUserThreadStart	ntdll		0x7fff81e570d1	
This seems to depend on how many add-on modules I have installed. For example, if I have freecad-nurbs by microelly installed, it crashes every time. But if I uninstall it, it starts up OK about 70% of the time. If I run it with debugger attached, it crashes more often.

I tried adding a Base::PyGILStateLocker lock; to the if-block where old workbench is being queried, and it fixes the crash. But then instead of the crash, I get broken UI in main window with about the same hit frequency as the crash used to happen with. I have a small frame which obscures File menu, and with all toolbars hidden (I can unhide them through View->Toolbars).
freecad-startup-no-toolbars.png
freecad-startup-no-toolbars.png (84.83 KiB) Viewed 1837 times
This has been happening for quite a while already. Also, it seems to be otherwise sensitive

Any ideas?

---
forgot this initially :oops:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10642 (Git)
Build type: Debug
Branch: PyInterface1
Hash: 1cd7463b0c077b1fdd30347c8f3e556b3eaba82f
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Debug build of FreeCAD crashes on startup

Post by DeepSOIC »

I think it is somehow related to triplus' TabBar. I have disabled it, and no crash/UI loss so far...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Debug build of FreeCAD crashes on startup

Post by triplus »

DeepSOIC wrote:I think it is somehow related to triplus' TabBar. I have disabled it, and no crash/UI loss so far...
Surely not? ;)

Could you please do a test for me. Temporary remove all 3'rd party modules from your user Mod folder. And move user.cfg and system.cfg files to a different location. Install TabBar:

https://github.com/triplus/TabBar

Start FreeCAD. Does the issue persist?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by DeepSOIC »

If I do it, the issue is gone, but my start-up workbench has changed to no workbench (I don't have Start wb in my build)... and tabbar doesn't appear.

After setting things up, it seems to work fine. I'll check what happens if I re-enable add-ons one-by-one...
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by DeepSOIC »

Started to happen when I added fcgear now. List of add-ons in Mod so far:
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\assembly2"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\disabled" <-- folder that I move stuff into to disable it, shouldn't have listed it here :oops:
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\fcgear"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Lattice2"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\tabbar"

Update: now I have enabled everything but fcgear, and no problem.
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\assembly2"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\freecad-nurbs"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Lattice2"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\long_load"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Overlap"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Part-o-magic"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\tabbar"

Update:
TabBar + FCGear alone = no problem...

Update.
Tabbar + FCGear + freecad-nurbs = PROBLEM

Update. PROBLEM:
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\assembly2"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\fcgear"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Lattice2"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Overlap"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\Part-o-magic"
"C:\Users\User\AppData\Roaming\FreeCAD\Mod\tabbar"
I don't seem to notice any reliable pattern so far. Maybe it's just making a fool out of me :P

Update.
assembly2+fcgear+tabbar = PROBLEM

Lattie2+fcgear+tabbar = no problem

Part-o-magic+fcgear+tabbar = no problem

EDIT: "PROBLEM" = broken UI. I've been doing these tests with GIL lock added to code, so no crashes...
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by triplus »

Can you test if the crash occurs when using official Windows daily build? To i guess rule out any potential Python 3 port changes (although it isn't debug build). But my feeling is telling me your current build has some sort of Python versions clash going on.

P.S. I likely won't be able to do any more tests (if new info will be provided) before in between 12 to 48 hours.
Last edited by triplus on Sat Mar 25, 2017 11:19 pm, edited 1 time in total.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by DeepSOIC »

Now I experimented a bit with workbench code. Removing resource imports in InitGui from either Assembly2 or FCGear removes the problem. But PartOMagic loads resources in InitGui too, so why doesn't it contribute to the problem?.. and what is so special about fcgear?.. :?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by DeepSOIC »

triplus wrote:Can you test if the crash occurs when using official Windows daily build?
It never happens in release builds.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by triplus »

I have debug build available but don't have access to the PC with it ATM. Likely in around 12 hours time i will be able to test the combination of modules that causes issues for you in combination with FreeCAD 0.17 (debug build).
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Debug build of FreeCAD crashes on startup (TabBar seems to cause it)

Post by triplus »

DeepSOIC wrote:assembly2+fcgear+tabbar = PROBLEM
I tested this scenario under FreeCAD 0.17 debug build (Ubuntu 16.04) and i can not confirm the crash. I did another test and added freecad-nurbs, Lattice2 and Part-o-magic modules to the mix and no crash occurred. I changed start up workbench to few options in Preferences.
triplus wrote:But my feeling is telling me your current build has some sort of Python versions clash going on.
Can you do a new fresh build (to leave out all the cache stuff and things like that). And after test the behaviour when all mentioned modules are installed.
Post Reply