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

USD 25.2: Sublayer Graph Cycle crash #3493

Open
dgovil opened this issue Jan 23, 2025 · 4 comments
Open

USD 25.2: Sublayer Graph Cycle crash #3493

dgovil opened this issue Jan 23, 2025 · 4 comments

Comments

@dgovil
Copy link
Collaborator

dgovil commented Jan 23, 2025

Maddy Adams discovered a regression in USD 25.2 that causes a crash when you have cyclical layers. This used to be a warning in 24.11 and prior, but is now a hard crash.

See the following Python example:

"""
This file will may create the following files, depending on settings: Top.usda, CopyDest.usda, CopySrc.usda, Opinion.usda, CopyDest.usda, Opinion.usda, Sub/copy.usda, Sub/Sub/copy.usda, Sub/opinion.usda
"""

# If CREATE_CYCLE is True, 24.11 will emit a warning about creating a cycle
# and 25.02 will crash. If CREATE_CYCLE is False, both versions will succeed with no warnings
CREATE_CYCLE = True

from pxr import Usd, Sdf, UsdGeom

# PYTHONPATH=USD_INSTALL_ROOT/lib/python
# PATH=USD_INSTALL_ROOT/bin

print(f"Using OpenUSD from {Usd.__file__}")

topFile = "Top.usda"
copyDestFile = "CopyDest.usda"
copySrcFile = "CopySrc.usda"
opinionFile = "Opinion.usda"
topSublayerPathToAdd = "CopyDest.usda"
copySrcCyclePathToAdd = None
copySrcSublayerPathToAdd = "Opinion.usda"

if CREATE_CYCLE:
    copyDestFile = "Sub/copy.usda"
    copySrcFile = "Sub/Sub/copy.usda"
    opinionFile = "Sub/Sub/opinion.usda"
    topSublayerPathToAdd = "Sub/copy.usda"
    copySrcCylePathToAdd = "Sub/copy.usda"
    copySrcSublayerPathToAdd = "Sub/copy.usda"


top = Usd.Stage.CreateNew(topFile)
copyDest = Usd.Stage.CreateNew(copyDestFile)
copySrc = Usd.Stage.CreateNew(copySrcFile)
opinion = Usd.Stage.CreateNew(opinionFile)

opinion.DefinePrim("/foo", "Sphere")

top.GetRootLayer().subLayerPaths.append(topSublayerPathToAdd)
if copySrcCyclePathToAdd is not None:
    copySrc.GetRootLayer().subLayerPaths.append(copySrcCyclePathToAdd)
copySrc.GetRootLayer().subLayerPaths.append(copySrcSublayerPathToAdd)

print("Top before TransferContent")
print(top.ExportToString())

print("\nAbout to TransferContent")
copyDest.GetRootLayer().TransferContent(copySrc.GetRootLayer())

print("\n\nTop after TransferContent")
print(top.ExportToString())

This results in the following with 25.2

[1]    61613 segmentation fault  python3 ./transfer_content_cycle.py

A full crash trace is below.
log.txt

In 24.11 and prior, it would instead report this warning:

Warning: in _ReportErrors at line 3258 of ../../pxr/usd/usd/stage.cpp -- Sublayer hierarchy with root layer @/Users/dhruvgovil/Downloads/Sub/copy.usda@ has cycles. Detected when layer @/Users/dhruvgovil/Downloads/Sub/Sub/copy.usda@ was seen in the layer stack for the second time. (Recomposing stage on stage @/Users/dhruvgovil/Downloads/Sub/Sub/copy.usda@ <0x12d903a00>)
Warning: in _ReportErrors at line 3258 of ../../pxr/usd/usd/stage.cpp -- Sublayer hierarchy with root layer @/Users/dhruvgovil/Downloads/Sub/Sub/copy.usda@ has cycles. Detected when layer @/Users/dhruvgovil/Downloads/Sub/copy.usda@ was seen in the layer stack for the second time. (Recomposing stage on stage @/Users/dhruvgovil/Downloads/Top.usda@ <0x12d875400>)
Warning: in _ReportErrors at line 3258 of ../../pxr/usd/usd/stage.cpp -- Sublayer hierarchy with root layer @/Users/dhruvgovil/Downloads/Sub/Sub/copy.usda@ has cycles. Detected when layer @/Users/dhruvgovil/Downloads/Sub/copy.usda@ was seen in the layer stack for the second time. (Recomposing stage on stage @/Users/dhruvgovil/Downloads/Sub/copy.usda@ <0x12d875a00>)
@asluk
Copy link
Collaborator

asluk commented Jan 23, 2025

Does this crash if PCP_ENABLE_MINIMAL_CHANGES_FOR_LAYER_OPERATIONS is set to 0, to disable the change processing optimizations for sublayers, which are now enabled by default in v25.02 ? Thanks!

@dgovil
Copy link
Collaborator Author

dgovil commented Jan 23, 2025

Ah good thought. Yeah, setting that to 0 avoids the crash.

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10593

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

@spiffmon
Copy link
Member

Thanks for finding and reporting, Maddy and @dgovil - we're investigating now, and considering a patch for 25.02 .

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

4 participants