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

MacOS seg fault when executing simple python script importing Tf with -m unittest #2102

Closed
rlei-weta opened this issue Nov 20, 2022 · 8 comments

Comments

@rlei-weta
Copy link

rlei-weta commented Nov 20, 2022

Description of Issue

Hello - I'm getting a seg fault in a MacOS build of USD 22.11 when executing a simple python script importing pxr.Tf with -m unittest.
Would appreciate any pointers :-) Thanks in advance

Steps to Reproduce

richard.lei /Users/richard.lei/dev/repro $ echo $PATH
/Users/richard.lei/apps/USD/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/munki:/Library/Apple/usr/bin
richard.lei /Users/richard.lei/dev/repro $ echo $PYTHONPATH
/Users/richard.lei/apps/USD/lib/python:
richard.lei /Users/richard.lei/dev/repro $ cat test.py
from pxr import Tf
print("Success")
richard.lei /Users/richard.lei/dev/repro $ python3 -m unittest test.py
zsh: segmentation fault  python3 -m unittest test.py
richard.lei /Users/richard.lei/dev/repro $ python3 test.py
Success

Notice that executing test.py without -m unittest does not seg fault.

System Information (OS, Hardware)

  • macOS Monterey Version 12.6.1
  • Macbook Pro (16-inch, 2021), Chip Apple M1 Max, Memory 64 GB

Package Versions

USD 22.11

Build Flags

Installed via:

python3 build_scripts/build_usd.py ~/apps/USD

Flags:

cmake \
    -DCMAKE_INSTALL_PREFIX="/Users/richard.lei/apps/USD" \
    -DCMAKE_PREFIX_PATH="/Users/richard.lei/apps/USD" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_MACOSX_RPATH=ON \
    -DPXR_PREFER_SAFETY_OVER_SPEED=ON \
    -DPXR_ENABLE_PYTHON_SUPPORT=ON \
    -DPXR_USE_PYTHON_3=ON \
    -DPXR_USE_DEBUG_PYTHON=OFF \
    -DPYTHON_EXECUTABLE="/opt/homebrew/opt/python@3.10/bin/python3.10" \
    -DPYTHON_LIBRARY="/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/libpython3.10.dylib" \
    -DPYTHON_INCLUDE_DIR="/opt/homebrew/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/include/python3.10" \
    -DBUILD_SHARED_LIBS=ON \
    -DTBB_USE_DEBUG_BUILD=OFF \
    -DPXR_BUILD_DOCUMENTATION=OFF \
    -DPXR_BUILD_TESTS=OFF \
    -DPXR_BUILD_EXAMPLES=ON \
    -DPXR_BUILD_TUTORIALS=ON \
    -DPXR_BUILD_USD_TOOLS=ON \
    -DPXR_BUILD_IMAGING=ON \
    -DPXR_ENABLE_PTEX_SUPPORT=OFF \
    -DPXR_ENABLE_OPENVDB_SUPPORT=OFF \
    -DPXR_BUILD_EMBREE_PLUGIN=OFF \
    -DPXR_BUILD_PRMAN_PLUGIN=OFF \
    -DPXR_BUILD_OPENIMAGEIO_PLUGIN=OFF \
    -DPXR_BUILD_OPENCOLORIO_PLUGIN=OFF \
    -DPXR_BUILD_USD_IMAGING=ON \
    -DPXR_BUILD_USDVIEW=ON \
    -DPXR_BUILD_ALEMBIC_PLUGIN=OFF \
    -DPXR_BUILD_DRACO_PLUGIN=OFF \
    -DPXR_ENABLE_MATERIALX_SUPPORT=OFF \
    -DBoost_NO_BOOST_CMAKE=On \
    -DBoost_NO_SYSTEM_PATHS=True \
    -DCMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH=YES \
    -DCMAKE_OSX_ARCHITECTURES=arm64 \
    "/Users/richard.lei/dev/USD"

Full build log: log.txt

Additional debugging information

DYLD_PRINT_LIBRARIES

Seg fault case (with -m unittest):

richard.lei /Users/richard.lei/dev/repro $ DYLD_PRINT_LIBRARIES=1 python3 -m unittest test.py
dyld[23553]: <1C8316FD-A866-356E-B762-B735C2941134> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/bin/python3.10
dyld[23553]: <F2371089-60D8-3B91-A475-4F4DCB3B84E3> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Python
dyld[23553]: <FC3C193D-0CDB-3569-9F0E-BD2507CA1DBB> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld[23553]: <EC96F0FA-6341-3E1D-BE54-49B544E17F7D> /usr/lib/libobjc.A.dylib
dyld[23553]: <7E53021F-FDCE-3EC9-8B4C-97AD3B21D02E> /usr/lib/liboah.dylib
dyld[23553]: <98801856-A5E8-37CC-8C50-3A6AEFA7DDD5> /usr/lib/libfakelink.dylib
dyld[23553]: <388AEA77-C05C-3AC8-8C9A-0028AC9E0D07> /usr/lib/libicucore.A.dylib
dyld[23553]: <1C6B853F-196A-39FD-ADC1-ED2E383FD9CF> /usr/lib/libSystem.B.dylib
dyld[23553]: <A3A10214-B37A-395D-9321-DB53768D2494> /System/Library/PrivateFrameworks/SoftLinking.framework/Versions/A/SoftLinking
dyld[23553]: <4E8D8A11-4217-3D56-9D41-5426F7CF307C> /usr/lib/libc++abi.dylib
dyld[23553]: <3D1E6031-901D-3DF1-9E9A-F85FF1C2E803> /usr/lib/libc++.1.dylib
dyld[23553]: <7E9E684F-57B6-3196-8AEC-908B46DEEBD4> /usr/lib/system/libcache.dylib
dyld[23553]: <FB7DF5AC-35DB-3B80-B2F6-BC69375390AE> /usr/lib/system/libcommonCrypto.dylib
dyld[23553]: <68788078-BF1D-3CD1-91A7-4C59FD78FB75> /usr/lib/system/libcompiler_rt.dylib
dyld[23553]: <654D0DA0-8277-361D-88DC-1430504B5436> /usr/lib/system/libcopyfile.dylib
dyld[23553]: <2D00FEEC-7984-342B-9516-5D49C5D98204> /usr/lib/system/libcorecrypto.dylib
dyld[23553]: <B3C7A004-1069-3171-B630-2C386A8B399C> /usr/lib/system/libdispatch.dylib
dyld[23553]: <F298A03D-5BC7-3BCA-8880-B956E52EAD01> /usr/lib/system/libdyld.dylib
dyld[23553]: <49D72074-0C58-317C-9B8B-762C13C0C084> /usr/lib/system/libkeymgr.dylib
dyld[23553]: <ED4EE8AE-EA60-33B7-9676-E6119B7449E3> /usr/lib/system/libmacho.dylib
dyld[23553]: <B887350E-B1C9-386C-B5EB-26F08C7C0152> /usr/lib/system/libquarantine.dylib
dyld[23553]: <157C8E50-D4A5-3DFC-8E0B-756E03E2082B> /usr/lib/system/libremovefile.dylib
dyld[23553]: <EC04DA81-C3B5-3AC5-9042-7F07DF48B42A> /usr/lib/system/libsystem_asl.dylib
dyld[23553]: <96462BD5-6BB4-3B69-89C9-2C70FA8852E7> /usr/lib/system/libsystem_blocks.dylib
dyld[23553]: <B25D2080-BB9E-38D6-8236-9CEF4B2F11A3> /usr/lib/system/libsystem_c.dylib
dyld[23553]: <4928F3C4-D438-354F-BA1C-0BD79F6475F3> /usr/lib/system/libsystem_collections.dylib
dyld[23553]: <3977B29D-624D-3DEE-94EF-95D29FB25252> /usr/lib/system/libsystem_configuration.dylib
dyld[23553]: <D38210EF-8F23-380B-8B43-BB06A7305F67> /usr/lib/system/libsystem_containermanager.dylib
dyld[23553]: <D5F19732-3AA0-3B93-9F25-318A27DE5AC5> /usr/lib/system/libsystem_coreservices.dylib
dyld[23553]: <5D456083-E21E-319D-9BA0-57702B3FB09B> /usr/lib/system/libsystem_darwin.dylib
dyld[23553]: <10A4374A-D15A-31C8-AC6F-2DCC10D06444> /usr/lib/system/libsystem_dnssd.dylib
dyld[23553]: <5B14B45B-A15B-31AD-93FB-BAC43C001A23> /usr/lib/system/libsystem_featureflags.dylib
dyld[23553]: <413C2A97-5D32-317D-8E32-4258B8E728CE> /usr/lib/system/libsystem_info.dylib
dyld[23553]: <31A9DAE0-FB1F-3CB8-8AB6-CA5A1192DFD8> /usr/lib/system/libsystem_m.dylib
dyld[23553]: <427675C6-C4BF-390A-AF93-B28DAC36876A> /usr/lib/system/libsystem_malloc.dylib
dyld[23553]: <4C9F32FA-D88C-3966-A2F0-7030841C8093> /usr/lib/system/libsystem_networkextension.dylib
dyld[23553]: <12A2A8B6-80B4-36CA-8245-830EBEDEF1C4> /usr/lib/system/libsystem_notify.dylib
dyld[23553]: <E49E2F05-0E01-352E-8CB7-276F8EF8E6D6> /usr/lib/system/libsystem_product_info_filter.dylib
dyld[23553]: <617BD764-AB2D-3919-8A40-30D1AF8876BC> /usr/lib/system/libsystem_sandbox.dylib
dyld[23553]: <18F251D3-8C66-3B8B-817A-C124498478F4> /usr/lib/system/libsystem_secinit.dylib
dyld[23553]: <DBF55FDD-2B9B-3701-93B6-7A3CE359BD0E> /usr/lib/system/libsystem_kernel.dylib
dyld[23553]: <A57FE7FB-9FF8-30CE-97A2-625D6DA20D00> /usr/lib/system/libsystem_platform.dylib
dyld[23553]: <63C4EEF9-69A5-38B1-996E-8D31B66A051D> /usr/lib/system/libsystem_pthread.dylib
dyld[23553]: <2906E453-3254-32EA-880E-14AEEF5D7ECD> /usr/lib/system/libsystem_symptoms.dylib
dyld[23553]: <B5524014-1A7F-3D07-8855-5E75A55E4A11> /usr/lib/system/libsystem_trace.dylib
dyld[23553]: <D9CA1CE3-6B1A-3E2B-BBAD-9D9B1DB00F92> /usr/lib/system/libunwind.dylib
dyld[23553]: <21D05A8B-D782-3FA7-9A9D-55A45E6E6621> /usr/lib/system/libxpc.dylib
dyld[23553]: <B67034AA-E70C-36DA-8A30-9B1CB5EFA8CB> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
dyld[23553]: <F2371089-60D8-3B91-A475-4F4DCB3B84E3> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Python
dyld[23553]: <FC3C193D-0CDB-3569-9F0E-BD2507CA1DBB> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld[23553]: <EC96F0FA-6341-3E1D-BE54-49B544E17F7D> /usr/lib/libobjc.A.dylib
dyld[23553]: <7E53021F-FDCE-3EC9-8B4C-97AD3B21D02E> /usr/lib/liboah.dylib
dyld[23553]: <98801856-A5E8-37CC-8C50-3A6AEFA7DDD5> /usr/lib/libfakelink.dylib
dyld[23553]: <388AEA77-C05C-3AC8-8C9A-0028AC9E0D07> /usr/lib/libicucore.A.dylib
dyld[23553]: <1C6B853F-196A-39FD-ADC1-ED2E383FD9CF> /usr/lib/libSystem.B.dylib
dyld[23553]: <A3A10214-B37A-395D-9321-DB53768D2494> /System/Library/PrivateFrameworks/SoftLinking.framework/Versions/A/SoftLinking
dyld[23553]: <4E8D8A11-4217-3D56-9D41-5426F7CF307C> /usr/lib/libc++abi.dylib
dyld[23553]: <3D1E6031-901D-3DF1-9E9A-F85FF1C2E803> /usr/lib/libc++.1.dylib
dyld[23553]: <7E9E684F-57B6-3196-8AEC-908B46DEEBD4> /usr/lib/system/libcache.dylib
dyld[23553]: <FB7DF5AC-35DB-3B80-B2F6-BC69375390AE> /usr/lib/system/libcommonCrypto.dylib
dyld[23553]: <68788078-BF1D-3CD1-91A7-4C59FD78FB75> /usr/lib/system/libcompiler_rt.dylib
dyld[23553]: <654D0DA0-8277-361D-88DC-1430504B5436> /usr/lib/system/libcopyfile.dylib
dyld[23553]: <2D00FEEC-7984-342B-9516-5D49C5D98204> /usr/lib/system/libcorecrypto.dylib
dyld[23553]: <B3C7A004-1069-3171-B630-2C386A8B399C> /usr/lib/system/libdispatch.dylib
dyld[23553]: <F298A03D-5BC7-3BCA-8880-B956E52EAD01> /usr/lib/system/libdyld.dylib
dyld[23553]: <49D72074-0C58-317C-9B8B-762C13C0C084> /usr/lib/system/libkeymgr.dylib
dyld[23553]: <ED4EE8AE-EA60-33B7-9676-E6119B7449E3> /usr/lib/system/libmacho.dylib
dyld[23553]: <B887350E-B1C9-386C-B5EB-26F08C7C0152> /usr/lib/system/libquarantine.dylib
dyld[23553]: <157C8E50-D4A5-3DFC-8E0B-756E03E2082B> /usr/lib/system/libremovefile.dylib
dyld[23553]: <EC04DA81-C3B5-3AC5-9042-7F07DF48B42A> /usr/lib/system/libsystem_asl.dylib
dyld[23553]: <96462BD5-6BB4-3B69-89C9-2C70FA8852E7> /usr/lib/system/libsystem_blocks.dylib
dyld[23553]: <B25D2080-BB9E-38D6-8236-9CEF4B2F11A3> /usr/lib/system/libsystem_c.dylib
dyld[23553]: <4928F3C4-D438-354F-BA1C-0BD79F6475F3> /usr/lib/system/libsystem_collections.dylib
dyld[23553]: <3977B29D-624D-3DEE-94EF-95D29FB25252> /usr/lib/system/libsystem_configuration.dylib
dyld[23553]: <D38210EF-8F23-380B-8B43-BB06A7305F67> /usr/lib/system/libsystem_containermanager.dylib
dyld[23553]: <D5F19732-3AA0-3B93-9F25-318A27DE5AC5> /usr/lib/system/libsystem_coreservices.dylib
dyld[23553]: <5D456083-E21E-319D-9BA0-57702B3FB09B> /usr/lib/system/libsystem_darwin.dylib
dyld[23553]: <10A4374A-D15A-31C8-AC6F-2DCC10D06444> /usr/lib/system/libsystem_dnssd.dylib
dyld[23553]: <5B14B45B-A15B-31AD-93FB-BAC43C001A23> /usr/lib/system/libsystem_featureflags.dylib
dyld[23553]: <413C2A97-5D32-317D-8E32-4258B8E728CE> /usr/lib/system/libsystem_info.dylib
dyld[23553]: <31A9DAE0-FB1F-3CB8-8AB6-CA5A1192DFD8> /usr/lib/system/libsystem_m.dylib
dyld[23553]: <427675C6-C4BF-390A-AF93-B28DAC36876A> /usr/lib/system/libsystem_malloc.dylib
dyld[23553]: <4C9F32FA-D88C-3966-A2F0-7030841C8093> /usr/lib/system/libsystem_networkextension.dylib
dyld[23553]: <12A2A8B6-80B4-36CA-8245-830EBEDEF1C4> /usr/lib/system/libsystem_notify.dylib
dyld[23553]: <E49E2F05-0E01-352E-8CB7-276F8EF8E6D6> /usr/lib/system/libsystem_product_info_filter.dylib
dyld[23553]: <617BD764-AB2D-3919-8A40-30D1AF8876BC> /usr/lib/system/libsystem_sandbox.dylib
dyld[23553]: <18F251D3-8C66-3B8B-817A-C124498478F4> /usr/lib/system/libsystem_secinit.dylib
dyld[23553]: <DBF55FDD-2B9B-3701-93B6-7A3CE359BD0E> /usr/lib/system/libsystem_kernel.dylib
dyld[23553]: <A57FE7FB-9FF8-30CE-97A2-625D6DA20D00> /usr/lib/system/libsystem_platform.dylib
dyld[23553]: <63C4EEF9-69A5-38B1-996E-8D31B66A051D> /usr/lib/system/libsystem_pthread.dylib
dyld[23553]: <2906E453-3254-32EA-880E-14AEEF5D7ECD> /usr/lib/system/libsystem_symptoms.dylib
dyld[23553]: <B5524014-1A7F-3D07-8855-5E75A55E4A11> /usr/lib/system/libsystem_trace.dylib
dyld[23553]: <D9CA1CE3-6B1A-3E2B-BBAD-9D9B1DB00F92> /usr/lib/system/libunwind.dylib
dyld[23553]: <21D05A8B-D782-3FA7-9A9D-55A45E6E6621> /usr/lib/system/libxpc.dylib
dyld[23553]: <13100DE6-F3F9-3AAF-BB3F-5FCA7F48C275> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_heapq.cpython-310-darwin.so
dyld[23553]: <7B8EC0DA-CC67-335A-8BFF-6A2E72EB1F23> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_opcode.cpython-310-darwin.so
dyld[23553]: <815E17F1-59D1-3888-86A8-6FBDCCDE2DC8> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/zlib.cpython-310-darwin.so
dyld[23553]: <CF6049D3-987B-35AE-AF25-BE62AAD5CAC2> /usr/lib/libz.1.dylib
dyld[23553]: <67131CCB-DAFD-32D2-A60C-ED4748F58D57> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_bz2.cpython-310-darwin.so
dyld[23553]: <81F9E867-44DD-3E74-8CB0-7169FE01CD23> /usr/lib/libbz2.1.0.dylib
dyld[23553]: <AC0D5E83-7ABE-39DF-95F3-7E4AA00AF98D> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_lzma.cpython-310-darwin.so
dyld[23553]: <BE14F6CA-B577-32BF-80AA-677AD7A3DF81> /opt/homebrew/Cellar/xz/5.2.7/lib/liblzma.5.dylib
dyld[23553]: <3928F4E6-876F-3330-90CC-4A0964331F56> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/fcntl.cpython-310-darwin.so
dyld[23553]: <95127BC4-3C14-398D-8B6D-782105C405C6> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so
dyld[23553]: <67FB1714-008E-3BC3-9656-0FBD83927902> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/select.cpython-310-darwin.so
dyld[23553]: <226E4B17-609B-3630-AEAB-45402358CD77> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/math.cpython-310-darwin.so
dyld[23553]: <01A0D43F-542E-33D5-85CE-06BD606E3275> /Users/richard.lei/apps/USD/lib/python/pxr/Tf/_tf.so
dyld[23553]: <2DFAE315-915A-383E-AA4C-85579E14850C> /Users/richard.lei/apps/USD/lib/libusd_tf.dylib
dyld[23553]: <2F316518-77CF-39CA-8B93-D3670D426E74> /Users/richard.lei/apps/USD/lib/libusd_arch.dylib
dyld[23553]: <163FDD0F-ECE5-3B06-96F5-CF39C3F5A846> /Users/richard.lei/apps/USD/lib/libboost_python310.dylib
dyld[23553]: <594D54B5-CEDA-3F21-ACF6-52F86EA39056> /Users/richard.lei/apps/USD/lib/libtbb.dylib
dyld[23553]: <4981FC23-0634-3E93-A5A7-4961382DDA87> /Users/richard.lei/apps/USD/lib/libtbbmalloc.dylib
zsh: segmentation fault  DYLD_PRINT_LIBRARIES=1 python3 -m unittest test.py

Working case (without -m unittest):

richard.lei /Users/richard.lei/dev/repro $ DYLD_PRINT_LIBRARIES=1 python3 test.py
dyld[23558]: <1C8316FD-A866-356E-B762-B735C2941134> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/bin/python3.10
dyld[23558]: <F2371089-60D8-3B91-A475-4F4DCB3B84E3> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Python
dyld[23558]: <FC3C193D-0CDB-3569-9F0E-BD2507CA1DBB> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld[23558]: <EC96F0FA-6341-3E1D-BE54-49B544E17F7D> /usr/lib/libobjc.A.dylib
dyld[23558]: <7E53021F-FDCE-3EC9-8B4C-97AD3B21D02E> /usr/lib/liboah.dylib
dyld[23558]: <98801856-A5E8-37CC-8C50-3A6AEFA7DDD5> /usr/lib/libfakelink.dylib
dyld[23558]: <388AEA77-C05C-3AC8-8C9A-0028AC9E0D07> /usr/lib/libicucore.A.dylib
dyld[23558]: <1C6B853F-196A-39FD-ADC1-ED2E383FD9CF> /usr/lib/libSystem.B.dylib
dyld[23558]: <A3A10214-B37A-395D-9321-DB53768D2494> /System/Library/PrivateFrameworks/SoftLinking.framework/Versions/A/SoftLinking
dyld[23558]: <4E8D8A11-4217-3D56-9D41-5426F7CF307C> /usr/lib/libc++abi.dylib
dyld[23558]: <3D1E6031-901D-3DF1-9E9A-F85FF1C2E803> /usr/lib/libc++.1.dylib
dyld[23558]: <7E9E684F-57B6-3196-8AEC-908B46DEEBD4> /usr/lib/system/libcache.dylib
dyld[23558]: <FB7DF5AC-35DB-3B80-B2F6-BC69375390AE> /usr/lib/system/libcommonCrypto.dylib
dyld[23558]: <68788078-BF1D-3CD1-91A7-4C59FD78FB75> /usr/lib/system/libcompiler_rt.dylib
dyld[23558]: <654D0DA0-8277-361D-88DC-1430504B5436> /usr/lib/system/libcopyfile.dylib
dyld[23558]: <2D00FEEC-7984-342B-9516-5D49C5D98204> /usr/lib/system/libcorecrypto.dylib
dyld[23558]: <B3C7A004-1069-3171-B630-2C386A8B399C> /usr/lib/system/libdispatch.dylib
dyld[23558]: <F298A03D-5BC7-3BCA-8880-B956E52EAD01> /usr/lib/system/libdyld.dylib
dyld[23558]: <49D72074-0C58-317C-9B8B-762C13C0C084> /usr/lib/system/libkeymgr.dylib
dyld[23558]: <ED4EE8AE-EA60-33B7-9676-E6119B7449E3> /usr/lib/system/libmacho.dylib
dyld[23558]: <B887350E-B1C9-386C-B5EB-26F08C7C0152> /usr/lib/system/libquarantine.dylib
dyld[23558]: <157C8E50-D4A5-3DFC-8E0B-756E03E2082B> /usr/lib/system/libremovefile.dylib
dyld[23558]: <EC04DA81-C3B5-3AC5-9042-7F07DF48B42A> /usr/lib/system/libsystem_asl.dylib
dyld[23558]: <96462BD5-6BB4-3B69-89C9-2C70FA8852E7> /usr/lib/system/libsystem_blocks.dylib
dyld[23558]: <B25D2080-BB9E-38D6-8236-9CEF4B2F11A3> /usr/lib/system/libsystem_c.dylib
dyld[23558]: <4928F3C4-D438-354F-BA1C-0BD79F6475F3> /usr/lib/system/libsystem_collections.dylib
dyld[23558]: <3977B29D-624D-3DEE-94EF-95D29FB25252> /usr/lib/system/libsystem_configuration.dylib
dyld[23558]: <D38210EF-8F23-380B-8B43-BB06A7305F67> /usr/lib/system/libsystem_containermanager.dylib
dyld[23558]: <D5F19732-3AA0-3B93-9F25-318A27DE5AC5> /usr/lib/system/libsystem_coreservices.dylib
dyld[23558]: <5D456083-E21E-319D-9BA0-57702B3FB09B> /usr/lib/system/libsystem_darwin.dylib
dyld[23558]: <10A4374A-D15A-31C8-AC6F-2DCC10D06444> /usr/lib/system/libsystem_dnssd.dylib
dyld[23558]: <5B14B45B-A15B-31AD-93FB-BAC43C001A23> /usr/lib/system/libsystem_featureflags.dylib
dyld[23558]: <413C2A97-5D32-317D-8E32-4258B8E728CE> /usr/lib/system/libsystem_info.dylib
dyld[23558]: <31A9DAE0-FB1F-3CB8-8AB6-CA5A1192DFD8> /usr/lib/system/libsystem_m.dylib
dyld[23558]: <427675C6-C4BF-390A-AF93-B28DAC36876A> /usr/lib/system/libsystem_malloc.dylib
dyld[23558]: <4C9F32FA-D88C-3966-A2F0-7030841C8093> /usr/lib/system/libsystem_networkextension.dylib
dyld[23558]: <12A2A8B6-80B4-36CA-8245-830EBEDEF1C4> /usr/lib/system/libsystem_notify.dylib
dyld[23558]: <E49E2F05-0E01-352E-8CB7-276F8EF8E6D6> /usr/lib/system/libsystem_product_info_filter.dylib
dyld[23558]: <617BD764-AB2D-3919-8A40-30D1AF8876BC> /usr/lib/system/libsystem_sandbox.dylib
dyld[23558]: <18F251D3-8C66-3B8B-817A-C124498478F4> /usr/lib/system/libsystem_secinit.dylib
dyld[23558]: <DBF55FDD-2B9B-3701-93B6-7A3CE359BD0E> /usr/lib/system/libsystem_kernel.dylib
dyld[23558]: <A57FE7FB-9FF8-30CE-97A2-625D6DA20D00> /usr/lib/system/libsystem_platform.dylib
dyld[23558]: <63C4EEF9-69A5-38B1-996E-8D31B66A051D> /usr/lib/system/libsystem_pthread.dylib
dyld[23558]: <2906E453-3254-32EA-880E-14AEEF5D7ECD> /usr/lib/system/libsystem_symptoms.dylib
dyld[23558]: <B5524014-1A7F-3D07-8855-5E75A55E4A11> /usr/lib/system/libsystem_trace.dylib
dyld[23558]: <D9CA1CE3-6B1A-3E2B-BBAD-9D9B1DB00F92> /usr/lib/system/libunwind.dylib
dyld[23558]: <21D05A8B-D782-3FA7-9A9D-55A45E6E6621> /usr/lib/system/libxpc.dylib
dyld[23558]: <B67034AA-E70C-36DA-8A30-9B1CB5EFA8CB> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python
dyld[23558]: <F2371089-60D8-3B91-A475-4F4DCB3B84E3> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Python
dyld[23558]: <FC3C193D-0CDB-3569-9F0E-BD2507CA1DBB> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
dyld[23558]: <EC96F0FA-6341-3E1D-BE54-49B544E17F7D> /usr/lib/libobjc.A.dylib
dyld[23558]: <7E53021F-FDCE-3EC9-8B4C-97AD3B21D02E> /usr/lib/liboah.dylib
dyld[23558]: <98801856-A5E8-37CC-8C50-3A6AEFA7DDD5> /usr/lib/libfakelink.dylib
dyld[23558]: <388AEA77-C05C-3AC8-8C9A-0028AC9E0D07> /usr/lib/libicucore.A.dylib
dyld[23558]: <1C6B853F-196A-39FD-ADC1-ED2E383FD9CF> /usr/lib/libSystem.B.dylib
dyld[23558]: <A3A10214-B37A-395D-9321-DB53768D2494> /System/Library/PrivateFrameworks/SoftLinking.framework/Versions/A/SoftLinking
dyld[23558]: <4E8D8A11-4217-3D56-9D41-5426F7CF307C> /usr/lib/libc++abi.dylib
dyld[23558]: <3D1E6031-901D-3DF1-9E9A-F85FF1C2E803> /usr/lib/libc++.1.dylib
dyld[23558]: <7E9E684F-57B6-3196-8AEC-908B46DEEBD4> /usr/lib/system/libcache.dylib
dyld[23558]: <FB7DF5AC-35DB-3B80-B2F6-BC69375390AE> /usr/lib/system/libcommonCrypto.dylib
dyld[23558]: <68788078-BF1D-3CD1-91A7-4C59FD78FB75> /usr/lib/system/libcompiler_rt.dylib
dyld[23558]: <654D0DA0-8277-361D-88DC-1430504B5436> /usr/lib/system/libcopyfile.dylib
dyld[23558]: <2D00FEEC-7984-342B-9516-5D49C5D98204> /usr/lib/system/libcorecrypto.dylib
dyld[23558]: <B3C7A004-1069-3171-B630-2C386A8B399C> /usr/lib/system/libdispatch.dylib
dyld[23558]: <F298A03D-5BC7-3BCA-8880-B956E52EAD01> /usr/lib/system/libdyld.dylib
dyld[23558]: <49D72074-0C58-317C-9B8B-762C13C0C084> /usr/lib/system/libkeymgr.dylib
dyld[23558]: <ED4EE8AE-EA60-33B7-9676-E6119B7449E3> /usr/lib/system/libmacho.dylib
dyld[23558]: <B887350E-B1C9-386C-B5EB-26F08C7C0152> /usr/lib/system/libquarantine.dylib
dyld[23558]: <157C8E50-D4A5-3DFC-8E0B-756E03E2082B> /usr/lib/system/libremovefile.dylib
dyld[23558]: <EC04DA81-C3B5-3AC5-9042-7F07DF48B42A> /usr/lib/system/libsystem_asl.dylib
dyld[23558]: <96462BD5-6BB4-3B69-89C9-2C70FA8852E7> /usr/lib/system/libsystem_blocks.dylib
dyld[23558]: <B25D2080-BB9E-38D6-8236-9CEF4B2F11A3> /usr/lib/system/libsystem_c.dylib
dyld[23558]: <4928F3C4-D438-354F-BA1C-0BD79F6475F3> /usr/lib/system/libsystem_collections.dylib
dyld[23558]: <3977B29D-624D-3DEE-94EF-95D29FB25252> /usr/lib/system/libsystem_configuration.dylib
dyld[23558]: <D38210EF-8F23-380B-8B43-BB06A7305F67> /usr/lib/system/libsystem_containermanager.dylib
dyld[23558]: <D5F19732-3AA0-3B93-9F25-318A27DE5AC5> /usr/lib/system/libsystem_coreservices.dylib
dyld[23558]: <5D456083-E21E-319D-9BA0-57702B3FB09B> /usr/lib/system/libsystem_darwin.dylib
dyld[23558]: <10A4374A-D15A-31C8-AC6F-2DCC10D06444> /usr/lib/system/libsystem_dnssd.dylib
dyld[23558]: <5B14B45B-A15B-31AD-93FB-BAC43C001A23> /usr/lib/system/libsystem_featureflags.dylib
dyld[23558]: <413C2A97-5D32-317D-8E32-4258B8E728CE> /usr/lib/system/libsystem_info.dylib
dyld[23558]: <31A9DAE0-FB1F-3CB8-8AB6-CA5A1192DFD8> /usr/lib/system/libsystem_m.dylib
dyld[23558]: <427675C6-C4BF-390A-AF93-B28DAC36876A> /usr/lib/system/libsystem_malloc.dylib
dyld[23558]: <4C9F32FA-D88C-3966-A2F0-7030841C8093> /usr/lib/system/libsystem_networkextension.dylib
dyld[23558]: <12A2A8B6-80B4-36CA-8245-830EBEDEF1C4> /usr/lib/system/libsystem_notify.dylib
dyld[23558]: <E49E2F05-0E01-352E-8CB7-276F8EF8E6D6> /usr/lib/system/libsystem_product_info_filter.dylib
dyld[23558]: <617BD764-AB2D-3919-8A40-30D1AF8876BC> /usr/lib/system/libsystem_sandbox.dylib
dyld[23558]: <18F251D3-8C66-3B8B-817A-C124498478F4> /usr/lib/system/libsystem_secinit.dylib
dyld[23558]: <DBF55FDD-2B9B-3701-93B6-7A3CE359BD0E> /usr/lib/system/libsystem_kernel.dylib
dyld[23558]: <A57FE7FB-9FF8-30CE-97A2-625D6DA20D00> /usr/lib/system/libsystem_platform.dylib
dyld[23558]: <63C4EEF9-69A5-38B1-996E-8D31B66A051D> /usr/lib/system/libsystem_pthread.dylib
dyld[23558]: <2906E453-3254-32EA-880E-14AEEF5D7ECD> /usr/lib/system/libsystem_symptoms.dylib
dyld[23558]: <B5524014-1A7F-3D07-8855-5E75A55E4A11> /usr/lib/system/libsystem_trace.dylib
dyld[23558]: <D9CA1CE3-6B1A-3E2B-BBAD-9D9B1DB00F92> /usr/lib/system/libunwind.dylib
dyld[23558]: <21D05A8B-D782-3FA7-9A9D-55A45E6E6621> /usr/lib/system/libxpc.dylib
dyld[23558]: <3928F4E6-876F-3330-90CC-4A0964331F56> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/fcntl.cpython-310-darwin.so
dyld[23558]: <95127BC4-3C14-398D-8B6D-782105C405C6> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so
dyld[23558]: <67FB1714-008E-3BC3-9656-0FBD83927902> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/select.cpython-310-darwin.so
dyld[23558]: <226E4B17-609B-3630-AEAB-45402358CD77> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/math.cpython-310-darwin.so
dyld[23558]: <7B8EC0DA-CC67-335A-8BFF-6A2E72EB1F23> /opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_opcode.cpython-310-darwin.so
dyld[23558]: <01A0D43F-542E-33D5-85CE-06BD606E3275> /Users/richard.lei/apps/USD/lib/python/pxr/Tf/_tf.so
dyld[23558]: <2DFAE315-915A-383E-AA4C-85579E14850C> /Users/richard.lei/apps/USD/lib/libusd_tf.dylib
dyld[23558]: <2F316518-77CF-39CA-8B93-D3670D426E74> /Users/richard.lei/apps/USD/lib/libusd_arch.dylib
dyld[23558]: <163FDD0F-ECE5-3B06-96F5-CF39C3F5A846> /Users/richard.lei/apps/USD/lib/libboost_python310.dylib
dyld[23558]: <594D54B5-CEDA-3F21-ACF6-52F86EA39056> /Users/richard.lei/apps/USD/lib/libtbb.dylib
dyld[23558]: <4981FC23-0634-3E93-A5A7-4961382DDA87> /Users/richard.lei/apps/USD/lib/libtbbmalloc.dylib

lldb backtrace

(lldb) bt 50
* thread #2, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x0000000100022afc dyld`dyld4::Loader::loadAddress(dyld4::RuntimeState&) const + 12
    frame #1: 0x0000000100034860 dyld`invocation function for block in dyld4::APIs::_dyld_register_func_for_add_image(void (*)(mach_header const*, long)) + 108
    frame #2: 0x000000010001aa98 dyld`dyld4::RuntimeState::withLoadersReadLock(void () block_pointer) + 92
    frame #3: 0x0000000100034784 dyld`dyld4::APIs::_dyld_register_func_for_add_image(void (*)(mach_header const*, long)) + 148
    frame #4: 0x0000000102804008 libusd_arch.dylib`pxrInternal_v0_22__pxrReserved__::(anonymous namespace)::InstallDyldCallbacks() + 20
    frame #5: 0x0000000100025f4c dyld`invocation function for block in dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 164
    frame #6: 0x000000010004f784 dyld`invocation function for block in dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 340
    frame #7: 0x0000000100045ed8 dyld`invocation function for block in dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 528
    frame #8: 0x0000000100011f98 dyld`dyld3::MachOFile::forEachLoadCommand(Diagnostics&, void (load_command const*, bool&) block_pointer) const + 168
    frame #9: 0x0000000100045c80 dyld`dyld3::MachOFile::forEachSection(void (dyld3::MachOFile::SectionInfo const&, bool, bool&) block_pointer) const + 192
    frame #10: 0x000000010004f1d4 dyld`dyld3::MachOAnalyzer::forEachInitializer(Diagnostics&, dyld3::MachOAnalyzer::VMAddrConverter const&, void (unsigned int) block_pointer, void const*) const + 516
    frame #11: 0x0000000100025e8c dyld`dyld4::Loader::findAndRunAllInitializers(dyld4::RuntimeState&) const + 172
    frame #12: 0x0000000100026038 dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 216
    frame #13: 0x0000000100026014 dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 180
    frame #14: 0x0000000100026014 dyld`dyld4::Loader::runInitializersBottomUp(dyld4::RuntimeState&, dyld3::Array<dyld4::Loader const*>&) const + 180
    frame #15: 0x0000000100026104 dyld`dyld4::Loader::runInitializersBottomUpPlusUpwardLinks(dyld4::RuntimeState&) const + 124
    frame #16: 0x0000000100035c64 dyld`dyld4::APIs::dlopen_from(char const*, int, void*) + 520
    frame #17: 0x00000001006c58f8 Python`_imp_create_dynamic + 1276
    frame #18: 0x00000001005f3184 Python`cfunction_vectorcall_FASTCALL + 88
    frame #19: 0x000000010069885c Python`_PyEval_EvalFrameDefault + 43344
...
@meshula
Copy link
Member

meshula commented Nov 20, 2022

Hi, it might help to know which dynamic library was being loaded when the crash occurred. In frame 16, is it possible to determine the path being supplied?

@rlei-weta
Copy link
Author

rlei-weta commented Nov 20, 2022

Hey @meshula - thanks for the tip!

I did not have much luck printing the path supplied to dlopen_from directly from the frame in lldb, however launching the process with DYLD_PRINT_APIS=1 show that libtbbmalloc was the last library being dlopen'ed:

(lldb) process launch --environment DYLD_PRINT_APIS=1 -- -m unittest test.py
There is a running process, kill it and restart?: [Y/n] y
Process 61474 exited with status = 9 (0x00000009)
Process 61493 launched: '/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/Resources/Python.app/Contents/MacOS/Python' (arm64)
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: dyld_sdk_at_least(0x100000000, <1,0x000A0900>) => 1
dyld[61493]: _dyld_get_image_slide(0x100000000) => 0x0
dyld[61493]: dyld_process_is_restricted() => 0
dyld[61493]: _dyld_get_image_slide(0x100000000) => 0x0
dyld[61493]: NSVersionOfLinkTimeLibrary(System) =>0x051F6403
dyld[61493]: _dyld_is_memory_immutable(0x189524f99, 18) => 1
dyld[61493]: _dyld_is_memory_immutable(0x189524f99, 18) => 1
dyld[61493]: _dyld_is_memory_immutable(0x189525611, 17) => 1
dyld[61493]: _dyld_register_func_for_add_image(0x194249a44)
dyld[61493]: _dyld_register_func_for_remove_image(0x194249cfc)
dyld[61493]: _dyld_objc_notify_register(0x189570ee8, 0x18957905c, 0x18959520c)
dyld[61493]: _dyld_get_shared_cache_range(0x16fdfdc40) => 0x1893c4000,0xBB70C000
dyld[61493]: _dyld_get_prog_image_header() => 0x100000000
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: dyld_shared_cache_some_image_overridden() => 0
dyld[61493]: _dyld_register_for_bulk_image_loads(0x189419438)
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: _NSGetExecutablePath(0x16fdfdcc8, 0x16fdfdcc4)
dyld[61493]: _dyld_get_shared_cache_range(0x1e2655a78) => 0x1893c4000,0xBB70C000
dyld[61493]: _dyld_is_memory_immutable(0x189472609, 36) => 1
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: dyld_get_program_sdk_version() => 0x000C0300
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: _dyld_is_memory_immutable(0x189b3b213, 11) => 1
dyld[61493]: _dyld_is_memory_immutable(0x189b3b213, 11) => 1
dyld[61493]: dyld_get_active_platform() => 1
dyld[61493]: dyld_process_is_restricted() => 0
dyld[61493]: _NSGetExecutablePath(0x16fdfd330, 0x16fdfd740)
dyld[61493]: dyld_has_inserted_or_interposing_libraries() => 0
dyld[61493]: _NSGetExecutablePath(0x16fdfd3a7, 0x16fdfd3a0)
dyld[61493]: NSLibraryNameForModule(0x20018cea0)
dyld[61493]: _dyld_is_memory_immutable(0x18962cec8, 26) => 1
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_heapq.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(_heapq.cpython-310-darwin.so) => 0x20018d860
dyld[61493]: dlsym(0x20018d860, "PyInit__heapq")
dyld[61493]:      dlsym("PyInit__heapq") => 0x100229520
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_opcode.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(_opcode.cpython-310-darwin.so) => 0x20018dc60
dyld[61493]: dlsym(0x20018dc60, "PyInit__opcode")
dyld[61493]:      dlsym("PyInit__opcode") => 0x10023bb88
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/zlib.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(zlib.cpython-310-darwin.so) => 0x20018de60
dyld[61493]: dlsym(0x20018de60, "PyInit_zlib")
dyld[61493]:      dlsym("PyInit_zlib") => 0x10025f28c
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_bz2.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(_bz2.cpython-310-darwin.so) => 0x20018e060
dyld[61493]: dlsym(0x20018e060, "PyInit__bz2")
dyld[61493]:      dlsym("PyInit__bz2") => 0x10024a284
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_lzma.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(_lzma.cpython-310-darwin.so) => 0x20018e260
dyld[61493]: dlsym(0x20018e260, "PyInit__lzma")
dyld[61493]:      dlsym("PyInit__lzma") => 0x10028be58
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/fcntl.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(fcntl.cpython-310-darwin.so) => 0x20018e5a0
dyld[61493]: dlsym(0x20018e5a0, "PyInit_fcntl")
dyld[61493]:      dlsym("PyInit_fcntl") => 0x100272190
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/_posixsubprocess.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(_posixsubprocess.cpython-310-darwin.so) => 0x20018e7a0
dyld[61493]: dlsym(0x20018e7a0, "PyInit__posixsubprocess")
dyld[61493]:      dlsym("PyInit__posixsubprocess") => 0x1002a261c
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/select.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(select.cpython-310-darwin.so) => 0x20018e9a0
dyld[61493]: dlsym(0x20018e9a0, "PyInit_select")
dyld[61493]:      dlsym("PyInit_select") => 0x100505d70
dyld[61493]: dlopen("/opt/homebrew/Cellar/python@3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload/math.cpython-310-darwin.so", 0x00000002)
dyld[61493]:       dlopen(math.cpython-310-darwin.so) => 0x20018eba0
dyld[61493]: dlsym(0x20018eba0, "PyInit_math")
dyld[61493]:      dlsym("PyInit_math") => 0x1005183e0
dyld[61493]: dlopen("/Users/richard.lei/apps/USD_dbg/lib/python/pxr/Tf/_tf.so", 0x00000002)
dyld[61493]: _dyld_register_func_for_add_image(0x10296de8c)
dyld[61493]: dladdr(0x10280c0a8, 0x16fdf6800)
dyld[61493]: dlopen("(null)", 0x00000001)
dyld[61493]: dlsym(0xfffffffffffffffe, "scalable_malloc")
dyld[61493]:      dlsym("scalable_malloc") => NULL
dyld[61493]: dlclose(0xfffffffffffffffe)
dyld[61493]: dlopen("/Users/richard.lei/apps/USD_dbg/lib/libtbbmalloc_debug.dylib", 0x00000001)
dyld[61493]: dlopen("libtbbmalloc_debug.dylib", 0x00000002)
dyld[61493]:       dlopen(libtbbmalloc_debug.dylib) => 0x20018ff00
dyld[61493]:       dlopen(libtbbmalloc_debug.dylib) => 0x20018ff00
dyld[61493]: dlsym(0x20018ff00, "scalable_malloc")
dyld[61493]:      dlsym("scalable_malloc") => 0x100fa3548
dyld[61493]: dlsym(0x20018ff00, "scalable_free")
dyld[61493]:      dlsym("scalable_free") => 0x100fa3590
dyld[61493]: dlsym(0x20018ff00, "scalable_aligned_malloc")
dyld[61493]:      dlsym("scalable_aligned_malloc") => 0x100fa3c18
dyld[61493]: dlsym(0x20018ff00, "scalable_aligned_free")
dyld[61493]:      dlsym("scalable_aligned_free") => 0x100fa3eac
Process 61493 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x0000000100022afc dyld`dyld4::Loader::loadAddress(dyld4::RuntimeState&) const + 12
dyld`dyld4::Loader::loadAddress:
->  0x100022afc <+12>: ldr    w8, [x0]
    0x100022b00 <+16>: mov    w9, #0x7964
    0x100022b04 <+20>: movk   w9, #0x6c34, lsl #16
    0x100022b08 <+24>: cmp    w8, w9
Target 0: (Python) stopped.
(lldb)

(Note: I've built a debug variant of USD which is why the library names are different from the original description, still getting the same seg fault though)

I noticed that preloading libtbbmalloc makes the crash go away:

richard.lei /Users/richard.lei/dev/repro $ DYLD_INSERT_LIBRARIES=/Users/richard.lei/apps/USD_dbg/lib/libtbbmalloc_debug.dylib python3 -m unittest test.py
Success

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
richard.lei /Users/richard.lei/dev/repro $

Also, if libtbbmalloc_debug.dylib is renamed to something else (so that it does not get found) the crash goes away.

Apart from the case where it was explicitly preloaded - I'm confused why libtbbmalloc is being loaded at all - since the build log says:

-- Found TBB: /Users/richard.lei/apps/USD_dbg/include (found version "2019.0") found components: tbb 
-- Using default system allocator because PXR_MALLOC_LIBRARY is unspecified

Within the USD installation, the only .so / .dylib files which specifies a shared library dependency onto libtbbmalloc is libtbbmalloc_proxy (according to otool).

@meshula
Copy link
Member

meshula commented Nov 20, 2022

Thanks for that information! We're looking at a related issue now. In the short term, can you rely on one of your workarounds? @sunyab is there anything else you might advise for the short term?

@rlei-weta
Copy link
Author

@meshula great to know something similar is already being investigated. In the meanwhile relying on one of the workarounds is no problem at all, thanks!

@sunyab
Copy link
Contributor

sunyab commented Nov 21, 2022

Hi @rlei-weta, like @meshula said we ran into the exact same crashes recently. We have a fix for this currently in the dev branch at 721c936, which will go out with the next USD release.

(FYI, libtbbmalloc gets loaded dynamically by libtbb because TBB wants to use its own allocator for its containers. So TBB will try to dlopen libtbbmalloc but falls back to the regular system allocator if that fails.)

@sunyab
Copy link
Contributor

sunyab commented Nov 21, 2022

Filed as internal issue #USD-7786

@rlei-weta
Copy link
Author

@sunyab thanks for the fix - a build off the tip of dev is working perfectly. And, good to know about libtbb's behaviour around its custom allocator :-)

@sunyab
Copy link
Contributor

sunyab commented Nov 22, 2022

Glad to help! Closing this one out.

@sunyab sunyab closed this as completed Nov 22, 2022
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

3 participants