Priority: P4: Low
Affects Version/s: 5.15.2, 6.0.0
Fix Version/s: None
Environment:Windows 10, python3
Commits:86be8c1ca5936680d65bde8817c5ba09238e3700 (pyside/pyside-setup/6.0) 131a1c17eed13171bf09ba42b2205760580e4f24 (pyside/pyside-setup/dev) e034d5085d26f6703cf907caf78292d9a7861aa2 (pyside/pyside-setup/5.15)
When a python application that uses PySide2 is frozen using PyInstaller and launched from a network-mapped drive under Windows, the import of shiboken2 causes an infinite loop.
The import of shiboken2 calls _init_pyside_extension(), which is where the infinite loop occurs. Interrupting the program with Ctrl+C shows an error that indicates that the issue is occurring in the "part 2" of signature initialization.
Specifically, the problem is the loop in the following block of bootstrap python code that is executed during part 2 of signature initialization:
In a PyInstaller-frozen application, the python modules are collected in an archive that's embedded in the executable, so the module does not exist as an on-disk file.
When run from a local drive, the loop will eventually reach the drive root, and abort due to path length not being greater than 3 (on Windows, it will be equal, e.g., c:\ ). And in subsequent code, it is determined that the loader module does not exist as a file, and sys.pyside_uses_embedding is set to True, and all is well...
On the network-mapped drive, however, the os.path.realpath() call turns the mapped drive letter into \\host\share, which is the drive's root. And since that root's length always exceeds 3, the loop is stuck ad infinitum trying to jump one level above the root...
A possible way to avoid this issue would be to replace the length-based check with a change-based one, or by adding an additional break-on-non-change clause into the loop itself, e.g.:
The issue affects both PySide2 5.15.2 (and earlier) and 6.0.
|For Gerrit Dashboard: PYSIDE-1460|
|328045,3||signature: Fix infinite loop changing up directories||dev||pyside/pyside-setup||Status: MERGED||+2||0|
|328140,2||signature: Fix infinite loop changing up directories||6.0||pyside/pyside-setup||Status: MERGED||+2||0|
|328141,3||signature: Fix infinite loop changing up directories||5.15||pyside/pyside-setup||Status: MERGED||+2||0|