Maya Hangs on Infinite Recursion (C++20, GCC, Refplat 2026, Maya 2027)
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
**Describe the bug**
In Maya 2027 with MayaUSD built with GCC 14.2 and C++20 (aligned with VFX Refplat 2026) against any USD version (including 25.11), Maya will hang on an infinitely recursive loop when attempting to modify the Stage or open the Layer Editor.
This happens anywhere a `TfWeakPtr` is compared to a `TfRefPtr` (e.g. `SdfLayerHandle == SdfLayerRefPtr` or `UsdStageWeakPtr == UsdStageRefPtr`) due to C++20's synthesized candidate overloads for the equality operator with reversed parameters, which in some cases like templatized derived friend classes [can result in the operator calling itself recursively](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2468r2.html#code-patterns-which-fail-at-runtime).
***Note that the bug is not with MayaUSD, but rather OpenUSD***. A PR has already been filed ([OpenUSD#4102](https://github.com/PixarAnimationStudios/OpenUSD/pull/4102)), and applying that patch to my local USD builds resolves the issue. I'm opening this issue here for visibility and awareness for Autodesk and other Maya users (the MayaUSD devkit and Autodesk USD fork are currently unpatched).
**Steps to reproduce**
Steps to reproduce the behavior:
1. Build MayaUSD for Maya 2027 using GCC and C++20
2. Load a USD Stage with the USD Proxy Shape in Maya
3. Attempt to open the Layer Editor or modify the Stage (e.g. move/rotate/scale any prim)
4. Notice it hangs
**Expected behavior**
The Layer Editor opens cleanly, showing the Layers in the selected USD Stage, or the Stage modification succeeds.
**Attachments**
If applicable, add screenshots, sample files, etc to help explain your problem.
**Specs (if applicable):**
- OS & version: Rocky Linux 9
- Compiler & version: GCC 14.2, C++20 (VFX Refplat 2026)
- Maya version: Maya 2027
- Maya USD version: 0.37.0
- Pixar USD version: 0.25.11
**Additional context**
Note that while the bug is with OpenUSD, since it is in the `weakPtrFacade.h` header, relevant warnings can be seen building MayaUSD if USD interface includes are not treated as system directories (e.g. `set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)`)
```
[373/563] Building CXX object lib/mayaUsd/CMakeFiles/mayaUsd.dir/nodes/proxyShapeBase.cpp.o
In file included from include/pxr/base/tf/weakPtr.h:20,
from include/pxr/base/tf/declarePtrs.h:16,
from include/pxr/usd/usd/common.h:14,
from include/pxr/usd/usd/notice.h:12,
from lib/mayaUsd/nodes/proxyShapeBase.h:24,
from lib/mayaUsd/nodes/proxyShapeBase.cpp:16:
include/pxr/base/tf/weakPtrFacade.h: In instantiation of ‘bool pxrInternal_v0_25_11__pxrReserved__::operator==(const TfRefPtr&, const TfWeakPtrFacade::Derived&) [with T = SdfLayer; PtrTemplate = TfWeakPtr; Type = SdfLayer; TfWeakPtrFacade::Derived = TfWeakPtr]’:
lib/mayaUsd/nodes/proxyShapeBase.cpp:1351:32: required from here
1351 | if (unsharedSession == _targetLayer)
| ^~~~~~~~~~~~
include/pxr/base/tf/weakPtrFacade.h:110:19: warning: in C++20 this comparison calls the current function recursively with reversed arguments
110 | return p2 == p1;
| ~~~^~~~~
include/pxr/base/tf/weakPtrFacade.h: In instantiation of ‘bool pxrInternal_v0_25_11__pxrReserved__::operator==(const TfRefPtr&, const TfWeakPtrFacade::Derived&) [with T = UsdStage; PtrTemplate = TfWeakPtr; Type = UsdStage; TfWeakPtrFacade::Derived = TfWeakPtr]’:
lib/mayaUsd/nodes/proxyShapeBase.cpp:2365:30: required from here
2365 | if (stage != getUsdStage()) {
| ^
include/pxr/base/tf/weakPtrFacade.h:110:19: warning: in C++20 this comparison calls the current function recursively with reversed arguments
110 | return p2 == p1;
| ~~~^~~~~
include/pxr/base/tf/weakPtrFacade.h: In function ‘bool pxrInternal_v0_25_11__pxrReserved__::operator==(const TfRefPtr&, const TfWeakPtrFacade::Derived&) [with T = SdfLayer; PtrTemplate = TfWeakPtr; Type = SdfLayer]’:
include/pxr/base/tf/weakPtrFacade.h:109:17: warning: infinite recursion detected [-Winfinite-recursion]
109 | friend bool operator == (const TfRefPtr& p1, Derived const &p2) {
| ^~~~~~~~
include/pxr/base/tf/weakPtrFacade.h:110:19: note: recursive call
110 | return p2 == p1;
| ~~~^~~~~
include/pxr/base/tf/weakPtrFacade.h: In function ‘bool pxrInternal_v0_25_11__pxrReserved__::operator==(const TfRefPtr&, const TfWeakPtrFacade::Derived&) [with T = UsdStage; PtrTemplate = TfWeakPtr; Type = UsdStage]’:
include/pxr/base/tf/weakPtrFacade.h:109:17: warning: infinite recursion detected [-Winfinite-recursion]
109 | friend bool operator == (const TfRefPtr& p1, Derived const &p2) {
| ^~~~~~~~
include/pxr/base/tf/weakPtrFacade.h:110:19: note: recursive call
110 | return p2 == p1;
| ~~~^~~~~
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.