Skip to content

Why RecursionLimit = 10 in OnnxTransformer? #5585

Closed
@s-tory

Description

@s-tory

What is the purpose that Google.Protobuf.CodedInputStream.RecursionLimit is set 10 at the following code?

using (var codedStream = Google.Protobuf.CodedInputStream.CreateWithLimits(modelStream, Int32.MaxValue, 10))


It is set 100 by default in protocol-buffers C#-wrapper.

https://github.com/protocolbuffers/protobuf/blob/10599e6c8dde8a9875258e03054a696d53cadebd/csharp/src/Google.Protobuf/CodedInputStream.cs#L83

        internal const int DefaultRecursionLimit = 100;

I could not load some network / .onnx file by the following exception be caused by RecursionLimit = 10 without the monkey-patched Microsoft.ML.OnnxTransformer.dll.

Google.Protobuf.InvalidProtocolBufferException: Protocol message had too many levels of nesting.  May be malicious.  Use CodedInputStream.SetRecursionLimit() to increase the depth limit.

I think that the networks are including Inception construction especially.
(ex. tensorflow/models`s Faster-RCNN-Inception-V2 converted)

Thank you for coding great tools!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority of the issue for triage purpose: Needs to be fixed at some point.onnxExporting ONNX models or loading ONNX modelsusabilitySmoothing user interaction or experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions