Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault on Usd.Stage.Open when running executable created with pyinstaller #3458

Open
ericabrett opened this issue Dec 10, 2024 · 1 comment

Comments

@ericabrett
Copy link

Description of Issue

I'm trying to use pyinstaller to generate an executable from a script that uses Usd.Stage.Open, but when running the executable, it fails with a Segmentation fault.

Steps to Reproduce

  1. Create new directory and initialize virtual environment with Python 3.9.
py -3.9 -m venv venv
. venv/Scripts/activate
  1. Install pyinstaller and usd-core.
pip install pyinstaller usd-core
  1. Create Python script file convert.py:
import sys
from pxr import Usd

def main():
    model_path = sys.argv[1]
    print(f"Opening USD stage: {model_path}")
    usd_stage = Usd.Stage.Open(model_path)  # pylint: disable = no-member
    print("...done!")


if __name__ == "__main__":
    main()
  1. Add pyinstaller hook: pyinstaller-hooks/hook-pxr.py
from PyInstaller.utils.hooks import collect_submodules

hiddenimports = collect_submodules("pxr")
  1. Run pyinstaller:
pyinstaller convert.py --additional-hooks-dir=pyinstaller-hooks
  1. Run the executable:
dist/convert/convert.exe <path to .usd file>

Output:

$ dist/convert/convert.exe "C:\Users\SFOEBB\Downloads\pyinstaller-playground\model.usd"
Opening USD stage: C:\Users\SFOEBB\Downloads\pyinstaller-playground\model.usd
Segmentation fault
(venv) 

It works fine if the script is run directly as a Python script (i.e. without pyinstaller):

$ python convert.py "C:\Users\SFOEBB\Downloads\pyinstaller-playground\model.usd"
Opening USD stage: C:\Users\SFOEBB\Downloads\pyinstaller-playground\model.usd
...done!
(venv)

When adding faulthandler, the output is:

$ dist/convert/convert.exe "C:\Users\SFOEBB\Downloads\pyinstaller-playground\model.usd"
Opening USD stage: C:\Users\SFOEBB\Downloads\pyinstaller-playground\model.usd
Windows fatal exception: access violation

Current thread 0x00003180 (most recent call first):
  File "convert.py", line 11 in main
  File "convert.py", line 16 in <module>
Segmentation fault
(venv)

System Information (OS, Hardware)

Windows 10 Enterprise

Package Versions

24.11

Build Flags

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10500

(This is an automated message. See here for more information.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants