aaubry/YamlDotNet

YamlStream.Load takes more than 60s to parse the 37K file

Metalnem opened this issue · 1 comments

YamlStream.Load takes more than 60s to parse the 37K file from the attached archive before it finally throws YamlDotNet.Core.SemanticErrorException. You can run the following code to reproduce it (the path variable should contain the path to the extracted file):

using (var file = File.OpenText(path))
{
  new YamlStream().Load(file);
}

The top of the stack trace looks like this (full stack trace has more than 70K lines):

Unhandled Exception: YamlDotNet.Core.SemanticErrorException: (Line: 2, Col: 1, Idx: 36853) - (Line: 2, Col: 1, Idx: 36853): While parsing a node, did not find expected node content.
   at YamlDotNet.Core.Parser.ParseNode(Boolean isBlock, Boolean isIndentlessSequence)
   at YamlDotNet.Core.Parser.MoveNext()
   at YamlDotNet.Core.ParserExtensions.Allow[T](IParser parser)
   at YamlDotNet.Core.ParserExtensions.Expect[T](IParser parser)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlSequenceNode.Load(IParser parser, DocumentLoadingState state)
   at YamlDotNet.RepresentationModel.YamlNode.ParseNode(IParser parser, DocumentLoadingState state)

This happens with the latest version of YamlDotNet and .NET Core 2.2 runinng on Linux and macOS.

Found via SharpFuzz.

I'll need to measure where the time is being spent.