jdegenstein / jmwright-CQ-Editor

Forked from jmwright/CQ-Editor
Apache License 2.0
30 stars 7 forks source link

Release 0.30-dev startup crash on Windows 10 #11

Closed AriaSalvatrice closed 1 year ago

AriaSalvatrice commented 1 year ago

Very little useful additional info I can think of providing besides the traceback. This windows install is far from pristine so there might be some weirdness going on on my system not present on a fresh install. Old mainline CQ Editor release works normally on this same machine.

call .\CQ-editor\CQ-editor.exe
Traceback (most recent call last):
  File "run.py", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cq_editor\__main__.py", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cq_editor\main_window.py", line 5, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cadquery\__init__.py", line 22, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cadquery\occ_impl\exporters\__init__.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cadquery\cq.py", line 61, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cadquery\sketch.py", line 27, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cadquery\occ_impl\importers\__init__.py", line 6, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "cadquery\occ_impl\importers\dxf.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\__init__.py", line 26, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\filemanagement.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\tools\standards.py", line 8, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\render\__init__.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\render\mleader.py", line 39, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\tools\text_size.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "ezdxf\fonts\fonts.py", line 705, in <module>
  File "ezdxf\fonts\fonts.py", line 289, in _load_font_manager
  File "ezdxf\fonts\fonts.py", line 318, in build_font_manager_cache
  File "ezdxf\fonts\font_manager.py", line 401, in build
  File "ezdxf\fonts\font_manager.py", line 409, in scan_all
  File "ezdxf\fonts\font_manager.py", line 423, in scan_folder
  File "ezdxf\fonts\font_manager.py", line 458, in get_ttf_font_face
  File "fontTools\ttLib\ttFont.py", line 452, in __getitem__
  File "fontTools\ttLib\ttFont.py", line 469, in _readTable
  File "fontTools\ttLib\tables\O_S_2f_2.py", line 118, in decompile
  File "fontTools\misc\sstruct.py", line 106, in unpack2
  File "fontTools\misc\sstruct.py", line 88, in unpack
struct.error: unpack requires a buffer of 8 bytes
[24800] Failed to execute script 'run' due to unhandled exception!
AriaSalvatrice commented 1 year ago

Following your advice on Discord, I looked into the possibility it chokes on a font and figured out it was this one:

https://www.dafont.com/comickbook.font

Looking what CQ-editor is up to with procmon64 or process hacker shows that it loads fonts alphabetically, the last it attempts to load is the one that causes a crash.

Both TTF files of the family cause a crash. It's a popular and relatively modern font (2009), so it's likely many other fonts can cause the same issue.

kenmcd commented 1 year ago

The fonts are defective. Bad characters in the name table (results in required names missing). OS2 table structure broken. Missing anchors on many characters. Wrong directions on some contours. Etc., etc. Kinda surprising they work at all. I would replace them with something better.

jdegenstein commented 1 year ago

@kenmcd To be clear, this was a random font on the user's system -- and has nothing to do with CQ-editor. Launching CQ-editor apparently caused this font to be "scanned" in some way that caused the whole application to crash. In my opinion, a defective font should not cause fonttools to crash.

kenmcd commented 1 year ago

In my opinion, a defective font should not cause fonttools to crash.

I agree. Oddly I used the fonttools ttx feature to dump the fonts and it succeeded but with some errors noted in the output. What version of fonttools are you using?

(Sorry, I was trying to figure-out the connection with the fonts and did not understand they are user fonts.)

jdegenstein commented 1 year ago

We are using fonttools=4.40.0 (also previously tried 4.39.4, same behavior)

justvanrossum commented 1 year ago

In my opinion, a defective font should not cause fonttools to crash.

Fonttools was not designed to handle defective fonts gracefully. You may want to reformulate as "a defective font should not cause my application to crash". Perhaps guard against fonttools throwing exceptions.

jdegenstein commented 1 year ago

@justvanrossum The point is that a random font on a user's system caused the whole application to crash and also did not provide any indication as to the fact it was (A) a corrupt font that caused it, and (B) which font it was. Per the discussion at the issue above, this was considered to be an unlikely occurrence in the real world. That was in March.

Since you did not bother to check, my application does not directly depend on fonttools; it depends on cadquery, which in turn depends on ezdxf, which in turn depends on fonttools. Hypothetically speaking, what is easier -- having every package which has some dependency guard against edge cases for that package or just providing better behavior upstream?

jdegenstein commented 1 year ago

Closing this issue as it is fixed in ezdxf 1.1.0b4