Failing unit test of StartPage module

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Failing unit test of StartPage module

Post by wmayer »

When running the unit tests then currently five unit tests of the StartPage module fail.
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/werner/Projects/build_clang/Mod/Start/TestStart/TestStartPage.py", line 44, in test_all_css_placeholders_removed
page = StartPage.handle()
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 391, in handle
SECTION_RECENTFILES += encode(buildCard(filename,method="LoadMRU.py?MRU=",arg=str(i)))
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 241, in buildCard
finfo = getInfo(filename)
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 150, in getInfo
doc = str(zfile.read(files[0]))
File "/usr/lib/python3.6/zipfile.py", line 1337, in read
with self.open(name, "r", pwd) as fp:
File "/usr/lib/python3.6/zipfile.py", line 1391, in open
fheader = zef_file.read(sizeFileHeader)
File "/usr/lib/python3.6/zipfile.py", line 728, in read
self._file.seek(self._pos)
OSError: [Errno 22] Das Argument ist ungültig
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/werner/Projects/build_clang/Mod/Start/TestStart/TestStartPage.py", line 72, in test_all_html_placeholders_removed
page = StartPage.handle()
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 391, in handle
SECTION_RECENTFILES += encode(buildCard(filename,method="LoadMRU.py?MRU=",arg=str(i)))
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 241, in buildCard
finfo = getInfo(filename)
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 150, in getInfo
doc = str(zfile.read(files[0]))
File "/usr/lib/python3.6/zipfile.py", line 1337, in read
with self.open(name, "r", pwd) as fp:
File "/usr/lib/python3.6/zipfile.py", line 1391, in open
fheader = zef_file.read(sizeFileHeader)
File "/usr/lib/python3.6/zipfile.py", line 728, in read
self._file.seek(self._pos)
OSError: [Errno 22] Das Argument ist ungültig
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/werner/Projects/build_clang/Mod/Start/TestStart/TestStartPage.py", line 52, in test_all_js_placeholders_removed
page = StartPage.handle()
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 391, in handle
SECTION_RECENTFILES += encode(buildCard(filename,method="LoadMRU.py?MRU=",arg=str(i)))
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 241, in buildCard
finfo = getInfo(filename)
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 150, in getInfo
doc = str(zfile.read(files[0]))
File "/usr/lib/python3.6/zipfile.py", line 1337, in read
with self.open(name, "r", pwd) as fp:
File "/usr/lib/python3.6/zipfile.py", line 1391, in open
fheader = zef_file.read(sizeFileHeader)
File "/usr/lib/python3.6/zipfile.py", line 728, in read
self._file.seek(self._pos)
OSError: [Errno 22] Das Argument ist ungültig
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/werner/Projects/build_clang/Mod/Start/TestStart/TestStartPage.py", line 79, in test_files_do_not_contain_backslashes
page = StartPage.handle()
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 391, in handle
SECTION_RECENTFILES += encode(buildCard(filename,method="LoadMRU.py?MRU=",arg=str(i)))
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 241, in buildCard
finfo = getInfo(filename)
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 150, in getInfo
doc = str(zfile.read(files[0]))
File "/usr/lib/python3.6/zipfile.py", line 1337, in read
with self.open(name, "r", pwd) as fp:
File "/usr/lib/python3.6/zipfile.py", line 1391, in open
fheader = zef_file.read(sizeFileHeader)
File "/usr/lib/python3.6/zipfile.py", line 728, in read
self._file.seek(self._pos)
OSError: [Errno 22] Das Argument ist ungültig
Traceback (most recent call last):
File "/usr/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/usr/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/home/werner/Projects/build_clang/Mod/Start/TestStart/TestStartPage.py", line 97, in test_html_validates
page = self.sanitize(StartPage.handle()) # Remove potentially sensitive data
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 391, in handle
SECTION_RECENTFILES += encode(buildCard(filename,method="LoadMRU.py?MRU=",arg=str(i)))
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 241, in buildCard
finfo = getInfo(filename)
File "/home/werner/Projects/build_clang/Mod/Start/StartPage/StartPage.py", line 150, in getInfo
doc = str(zfile.read(files[0]))
File "/usr/lib/python3.6/zipfile.py", line 1337, in read
with self.open(name, "r", pwd) as fp:
File "/usr/lib/python3.6/zipfile.py", line 1391, in open
fheader = zef_file.read(sizeFileHeader)
File "/usr/lib/python3.6/zipfile.py", line 728, in read
self._file.seek(self._pos)
OSError: [Errno 22] Das Argument ist ungültig
To judge by the stacktrace the reason for the failures is always the same.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Failing unit test of StartPage module

Post by wmayer »

I figured out the problem. A while ago we had a report that FreeCAD freezes when loading the file hang.FCStd from here:
https://forum.freecadweb.org/viewtopic.php?f=8&t=62593

Since it's a corrupted zip file Python seems to raise an error when trying to load it. Because this file is part of my "Recent File List" the script LoadMRU.py will trigger the exception.

With this change the unit test will ignore corrupted FCStd files
git commit bce8c25421
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Failing unit test of StartPage module

Post by openBrain »

wmayer wrote: Mon Oct 11, 2021 8:14 am With this change the unit test will ignore corrupted FCStd files
git commit bce8c25421
That's somewhat a pity that unit test can handle this while core can't. :?
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Failing unit test of StartPage module

Post by wmayer »

openBrain wrote: Mon Oct 11, 2021 9:04 am
wmayer wrote: Mon Oct 11, 2021 8:14 am With this change the unit test will ignore corrupted FCStd files
git commit bce8c25421
That's somewhat a pity that unit test can handle this while core can't. :?
This is because the unit test doesn't try to load the full project but only the Document.xml file inside.

Actually there are two problems with the file:
  • It's not a valid zip file
  • It contains a brep file that causes OCC to run in an endless loop
The FreeCAD core system is more permissive and tries to load as much as it can and then it struggles to load one of the brep files. But if FreeCAD were stricter about the correctness of zip files then this wouldn't solve the problem because the mentioned brep file can be part of a valid zip file.

In the referenced thread I have extracted the broken brep and trying to load it makes FreeCAD freeze, too. So, it's up to OCC developers to fix the problem.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: Failing unit test of StartPage module

Post by openBrain »

This is most right. Anyway I think that detecting invalid ZIP file may solve the majority of the problems that normal users may encounter with corrupted files.
Though I agree there is something to do in OCC too for invalid BREP.
Post Reply