Skip to content

Why RecursionLimit = 10 in OnnxTransformer? #5585

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    usabilitySmoothing user interaction or experience

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions