Exception throws in UsdStage::Open() for fuzzed usd model
Description of Issue
Exception throws in UsdStage::Open() for fuzzed usd model
Steps to Reproduce
- unzip the package
- when open usd file
- exception throws as below
AnimationWithDifferentTangents---!6iyg1lvyfzp6u-a9fp82b9a18.zip
System Information (OS, Hardware)
Windows 10
Package Versions
Build Flags
Filed as internal issue #USD-8504
FYI the usd model contains too many tokens in TOKEN section.
./tusdcat ../data/AnimationWithDifferentTangents---\!6iyg1lvyfzp6u-a9fp82b9a18.usd ERR : [error]/home/syoyo/work/tinyusdz/src/crate-reader.cc[Crate]:ReadTokens():4511 Too many Tokens.
@syoyo right, this is a Fuzzed USD model and I want to know if there will be a fix in future to avoid this exception ?
So the exception here is a std::bad_alloc exception that USD is just not catching, by design, right now. We have recently been reconsidering our use of and policy for exceptions, and will have another look at this one in light of that. We will update when we have more info!
We've recently been thinking about this again, and while we think that there are potentially many legit files that could also throw that exception (e.g. on resource-limited platforms), we do think it prudent to try to catch and error/recover from exceptions thrown from inside plugin code in as many of OpenUSD's plugin API's as possible, so we intend to work our way through those API's. For non-virtual-interface API's like SdfLayer and ArResolver, this will be relatively straightforward, and, inspired by this report, will first tackle SdfLayer::FindOrOpen(), which already returns a NULL SdfLayerRefPtr in error cases we can identify ourselves. In general, exceptions will be turned into TF_RUNTIME_ERROR, which clients can handle on an opt-in basis, and which turn into python exceptions if not handled in C++ client code.