Improve USD plugin detection and memory error diagnostics #3050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description: Improve USD Plugin Detection and Memory Robustness
This Pull Request introduces enhancements to MuJoCo's USD integration and improves memory allocation diagnostics, with a focus on cross-platform reliability (Windows/MinGW/macOS).
Changes
1. Robust USD Plugin Resource Discovery (#3004)
src/experimental/usd/utils.ccto search formujoco-usd-resourcesin both the current library directory and the siblinglibdirectory. This is essential for Windows where DLLs often sit in abinfolder while resources reside inlib.plugInfo.jsongeneration insrc/experimental/usd/CMakeLists.txtto correctly point to thebindirectory for shared libraries on Windows. This ensures that USD can actually load the plugins it registers.2. Enhanced Memory Error Diagnostics (#2992)
src/engine/engine_util_errmem.cto include the requested allocation size in the "Could not allocate memory" fatal error. This provides immediate clarity on whether a crash is due to system exhaustion or an invalid (e.g., massive) size request from program logic.mju_mallochandles 0-sized requests gracefully. On Windows,_aligned_malloc(0)returnsNULL, which was previously triggered a fatal "out of memory" error. We now ensure a minimum valid allocation to prevent these false-positive crashes.Verification
plugInfo.jsonpaths resolve correctly for standard Windows installation structures.<vector>header inutils.ccdoes not conflict with existing builds.These improvements make it much easier for Windows users to use the new USD features and provide better tools for debugging memory-related issues.