Skip to content

Infinite loop in MergingSceneIndex #3895

@cpichard

Description

@cpichard

While running the arnold usd testsuite with USD 25.11, we discovered a case where the merging scene index enters an infinite loop.

It happens in the function HdMergingSceneIndex::_GetInputEntriesByPath. Here is a copy of the code involved:

    if (_inputs.size() < 5) {
        // It is common for merging scene indexes to have few inputs,
        // ex: 2 or 3.
        // In that case, skip looking through the path table and use the full
        // list.
        return _inputs;
    }

    // Find the closest enclosing path table entry.
    for (SdfPath p = primPath; !p.IsEmpty(); p = p.GetParentPath()) {
        const _InputEntriesByPathTable::const_iterator it =
            _inputsPathTable.find(p);
        if (it != _inputsPathTable.end()) {
            return it->second;
        }
    }

_inputs.size() >= 5, so the runtime enters the loop that should find the path in the _inputsPathTable.
For some good or bad reasons primPath = '.' and each iteration the loop adds the parent path to the original relative path, ending up looking for paths like "./../../../../..", etc, and it never ends as the path is never empty.
The process ends up crashing.

This happens with USD 25.11 and was found on macOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions