Azure / Azure/bicep

Bicep out of stack with large set of unclosed {'s (CLI and langserver)

Open
#15,465 1 comment 0 reactions 0 assignees View on GitHub
Quality Sprint
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

[This file](https://github.com/user-attachments/files/17604272/whoops.zip) was (incorrectly) automatically generated, I'm not that twisted. :-)

File looks like this:
resource r1 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: 'r1'
resource r2 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: 'r2'
resource r3 'Microsoft.Network/virtualNetworks@2021-05-01' = {

and repeats about 800 times. Bicep crashes somewhere after 600.

Stack overflow.
at Bicep.Core.Parsing.Lexer.TryGetStringValue(Bicep.Core.Parsing.Token)
at Bicep.Core.Parsing.Lexer.TryGetRawStringSegments(System.Collections.Generic.IReadOnlyList`1)
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass47_0.g__ProcessStringSegment|0(Boolean)
at Bicep.Core.Parsing.BaseParser.InterpolableString()
at Bicep.Core.Parsing.BaseParser.PrimaryExpression(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser.MemberExpression(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser.UnaryExpression(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser.BinaryExpression(Bicep.Core.Parsing.ExpressionFlags, Int32)
at Bicep.Core.Parsing.BaseParser.Expression(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass59_0.b__3()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass59_0.b__0()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.BaseParser.ObjectProperty(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass58_0.b__1()
at Bicep.Core.Parsing.BaseParser.HandleArrayOrObjectElements(Bicep.Core.Parsing.TokenType, System.Func`1)
at Bicep.Core.Parsing.BaseParser.Object(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.Parser.b__10_2()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.Parser.ResourceDeclaration(System.Collections.Generic.IEnumerable`1)
at Bicep.Core.Parsing.Parser+<>c__DisplayClass2_0.b__0()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.Parser.Declaration(System.String[])
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass59_0.b__0()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.BaseParser.ObjectProperty(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass58_0.b__1()
at Bicep.Core.Parsing.BaseParser.HandleArrayOrObjectElements(Bicep.Core.Parsing.TokenType, System.Func`1)
at Bicep.Core.Parsing.BaseParser.Object(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.Parser.b__10_2()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.Parser.ResourceDeclaration(System.Collections.Generic.IEnumerable`1)
at Bicep.Core.Parsing.Parser+<>c__DisplayClass2_0.b__0()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.Parser.Declaration(System.String[])
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass59_0.b__0()
at Bicep.Core.Parsing.BaseParser.WithRecovery[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.Func`1, Bicep.Core.Parsing.RecoveryFlags, Bicep.Core.Parsing.TokenType[])
at Bicep.Core.Parsing.BaseParser.ObjectProperty(Bicep.Core.Parsing.ExpressionFlags)
at Bicep.Core.Parsing.BaseParser+<>c__DisplayClass58_0.b__1()
at Bicep.Core.Parsing.BaseParser.HandleArrayOrObjectElements(Bicep.Core.Parsing.TokenType, System.Func`1)
...

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the attached whoops.zip, then inspect the Bicep.Core.Parsing.Lexer, BaseParser, and Parser entry points shown in the stack trace. Done means the CLI and language server process roughly 800 unclosed nested resources without a stack overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cli, compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.