LumaPictures / usd-qt

Reusable Qt Components for Pixar's USD
Other
153 stars 41 forks source link

Empty UsdQt module and import segfault on CentOS 7.4 #29

Closed charlesfleche closed 4 years ago

charlesfleche commented 5 years ago

After importing UsdQt, the module is actually empty:

$ python -c 'from pxr import UsdQt; print(dir(UsdQt)); UsdQt.HierarchyStandardModel'
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', '_usdQt', 'pxr']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

I then wanted to run the tests to see if everything was OK on that side, but UsdQt segfaults when importing both QtCore and QtWidgets from UsdQt._Qt:

$ python -c 'from pxr.UsdQt._Qt import QtCore, QtWidgets'
Segmentation fault

Importing just one or the other QtCore or QtWidgets works fine.

$ python -c 'from pxr.UsdQt._Qt import QtCore'
$ python -c 'from pxr.UsdQt._Qt import QtWidgets'

I've built usq-qt (with patches) against different built USD 19.07 and 19.05:

In every case the imports fail.

I've built usd-qt with gcc 4.8.5 and gcc 6 (from devtoolset-6 using this cmake command:

$ cmake ../usd-qt -DCMAKE_INSTALL_PREFIX=/devLocal/builds/usd-qt -DCMAKE_BUILD_TYPE=Release -DTBB_ROOT_DIR=/devLocal/builds/USD19.07-build_script -DUSD_ROOT=/devLocal/builds/USD19.07-build_script -DBOOST_ROOT=/devLocal/builds/USD19.07-build_script -DTBB_tbb_LIBRARY_RELEASE=/devLocal/builds/USD19.07-build_script/lib/libtbb.so

Am I doing something wrong here ?

Thanks,

charlesfleche commented 5 years ago

Ah, something new: importing QtWidgets before QtCore does not segfault anymore:

$ python -c 'from pxr.UsdQt._Qt import QtWidgets, QtCore'

Tests fail with AttributeError: 'module' object has no attribute 'HierarchyStandardModel', though:

$ python pxr/usdQt/testenv/testUsdQtHierarchyModel.py
test_ActivateAndDeactivate (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_ActivateOnly (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_BadVariantSwitch (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_DeactivateAndReactivate (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_DeactivateOnly (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_RootStructure (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_SelectionLayoutChanged (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_UnmodifiedFilterModel (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_UnmodifiedStage (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_VariantSwitch (__main__.TestSimpleHierarchyAllLoaded) ... ERROR
test_ActivateAndDeactivate (__main__.TestSimpleHierarchyDefault) ... ERROR
test_ActivateOnly (__main__.TestSimpleHierarchyDefault) ... ERROR
test_BadVariantSwitch (__main__.TestSimpleHierarchyDefault) ... ERROR
test_DeactivateAndReactivate (__main__.TestSimpleHierarchyDefault) ... ERROR
test_DeactivateOnly (__main__.TestSimpleHierarchyDefault) ... ERROR
test_RootStructure (__main__.TestSimpleHierarchyDefault) ... ERROR
test_SelectionLayoutChanged (__main__.TestSimpleHierarchyDefault) ... ERROR
test_UnmodifiedFilterModel (__main__.TestSimpleHierarchyDefault) ... ERROR
test_UnmodifiedStage (__main__.TestSimpleHierarchyDefault) ... ERROR
test_VariantSwitch (__main__.TestSimpleHierarchyDefault) ... ERROR

======================================================================
ERROR: test_ActivateAndDeactivate (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_ActivateOnly (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_BadVariantSwitch (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_DeactivateAndReactivate (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_DeactivateOnly (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_RootStructure (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_SelectionLayoutChanged (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_UnmodifiedFilterModel (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_UnmodifiedStage (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_VariantSwitch (__main__.TestSimpleHierarchyAllLoaded)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_ActivateAndDeactivate (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_ActivateOnly (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_BadVariantSwitch (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_DeactivateAndReactivate (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_DeactivateOnly (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_RootStructure (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_SelectionLayoutChanged (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_UnmodifiedFilterModel (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_UnmodifiedStage (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

======================================================================
ERROR: test_VariantSwitch (__main__.TestSimpleHierarchyDefault)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "pxr/usdQt/testenv/testUsdQtHierarchyModel.py", line 53, in setUp
    self.model = UsdQt.HierarchyStandardModel(self.stage)
AttributeError: 'module' object has no attribute 'HierarchyStandardModel'

----------------------------------------------------------------------
Ran 20 tests in 0.134s

FAILED (errors=20)
nrusch commented 5 years ago

Hey @charlesfleche,

The UsdQt and UsdQtEditors modules are intentionally empty. The intent is for you to import what you need and nothing else.

However, you're definitely right that all of the tests are broken... It looks like we didn't update them after we stopped importing everything into the top-level package modules. Luckily they should be easy to fix - I'll try to take care of that shortly.

In terms of the crashing, you're sort of in unexplored territory there. We're still on CentOS 7.3 here for the time being, and we've only gone as far as VFXPlatform 2018. I'll see if I can put together a newer build environment at some point, but I'm not sure when that will be right now.

charlesfleche commented 5 years ago

Great news, thanks @nrusch If the tests work, I'm happy to take a look at building on a more recent environment.

charlesfleche commented 5 years ago

By the way, this segfaults as well:

$ python -c 'from pxr.UsdQt import hierarchyModel'
Segmentation fault

(tested on CentOS 7.4, gcc 4.8.5, USD 19.07 compiled with their build script, usq-qt compiled against the USD platform)

nrusch commented 5 years ago

Hmm. Have you confirmed that both PySide2 and the Python bindings for your USD build work independently in your runtime environment (i.e. without getting UsdQt involved at all)?

If both of those work fine, but importing UsdQt causes a crash, it would be helpful if you could capture and post a stack trace of the crash (using GDB), and maybe also include your runtime environment.

Thanks.

charlesfleche commented 5 years ago

Yes: usdview works, using the PySide2 bindings. I'll send you a stack trace ASAP.

charlesfleche commented 5 years ago

Within usdview:

Usdviewq.qt.QtWidgets.__file__
'/devLocal/src/PixarAnimationStudios/USD/env/lib/python2.7/site-packages/PySide2/QtWidgets.so'

For some reason I'm having an hard time importing PySide2 in python-debug, so I can't meaningfully run it in gdb. However, here is a trace for:

$ strace python -c 'from pxr.UsdQt import hierarchyModel' &> trace.txt
nrusch commented 5 years ago

You don't need to run any debug builds to capture a stack trace. Since I don't have a comparable test environment on my end, at this point I'm mostly interested in figuring out if the crash is actually occurring in UsdQt itself, or if UsdQt is just happening to trip something up in another library.

Unfortunately strace output isn't much to go on in this instance.

diboca commented 5 years ago

/opt/usd-qt/build# make install Scanning dependencies of target _usdQt_pythonfiles [ 2%] Generating _Qt.pyc [ 4%] Generating init.pyc [ 6%] Generating _bindings.pyc [ 8%] Generating compatability.pyc [ 11%] Generating hierarchyModel.pyc [ 13%] Generating hooks.pyc [ 15%] Generating layerModel.pyc [ 17%] Generating opinionModel.pyc [ 20%] Generating opinionStackModel.pyc [ 22%] Generating qtUtils.pyc [ 24%] Generating roles.pyc [ 26%] Generating stageCacheModel.pyc [ 28%] Generating usdUtils.pyc [ 31%] Generating valueDelegate.pyc [ 33%] Generating valueWidgets.pyc [ 33%] Built target _usdQt_pythonfiles Scanning dependencies of target _usdQt [ 35%] Building CXX object pxr/usdQt/CMakeFiles/_usdQt.dir/attributeProxy.cpp.o [ 37%] Building CXX object pxr/usdQt/CMakeFiles/_usdQt.dir/debugCodes.cpp.o [ 40%] Building CXX object pxr/usdQt/CMakeFiles/_usdQt.dir/displayGroupProxy.cpp.o [ 42%] Building CXX object pxr/usdQt/CMakeFiles/_usdQt.dir/hierarchyCache.cpp.o /opt/usd-qt/pxr/usdQt/hierarchyCache.cpp: 在成员函数‘void pxrInternal_v0_19pxrReserved::UsdQt_HierarchyCache::DebugFullIndex()’中: /opt/usd-qt/pxr/usdQt/hierarchyCache.cpp:241:15: 错误:无法将左值‘std::basic_ostream’绑定到‘std::basic_ostream&&’ std::cout << "Root: " << _root->GetPrim() << std::endl; ^ In file included from /usr/include/c++/4.8.2/iostream:39:0, from /opt/usd-qt/pxr/usdQt/hierarchyCache.cpp:25: /usr/include/c++/4.8.2/ostream:602:5: 错误:以初始化‘std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&) [with _CharT = char; _Traits = std::char_traits; _Tp = pxrInternal_v0_19pxrReserved::UsdPrim]’的实参 1 operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x) ^ make[2]: [pxr/usdQt/CMakeFiles/_usdQt.dir/hierarchyCache.cpp.o] 错误 1 make[1]: [pxr/usdQt/CMakeFiles/_usdQt.dir/all] 错误 2 make: *** [all] 错误 2

nrusch commented 4 years ago

Closing this one out, as it's pretty old, and we are running usd-qt successfully on CentOS 7.7 now.