Skip to content

Stack overflow with nested templates #383

Closed
dotnet/arcade
#16884

Description

@arsu-leo

Describe the bug

If you try to nest 2 or more templates that contains the {{>@partial-block}}, it will throw an exception.
On my own project it thew me an "Access violation exception"
When I created a test case, I got an Stack Overflow exception.

Expected behavior:

Success execution of the callback function like happens here:
https://jsfiddle.net/f3abhwp6/2/

Test to reproduce

[Fact]
        static void TestNestedPartials()
        {
            var innerPartial = @"{{#>outer-partial}}<br />
Begin inner partial<br />
    Begin inner partial block<br />
        {{>@partial-block}}
    End  inner partial block<br />
End inner partial<br />
{{/outer-partial}}";
            
            var outerPartial = @"Begin outer partial<br />
    Begin outer partial block
        {{>@partial-block}}
    End outer partial block<br />
End outer partial";

            var view = @"{{#>inner-partial}}
  View<br />
{{/inner-partial}}";

            IHandlebars handlebars = Handlebars.Create();
            handlebars.RegisterTemplate("outer-partial", outerPartial);
            handlebars.RegisterTemplate("inner-partial", innerPartial);

            var callback = handlebars.Compile(view);
            string result = callback(new object()); <-- This line throws

            Console.WriteLine(result);
        }

System.StackOverflowException
HResult=0x800703E9
Message=

Other related info

Project info
Project type
.Net Core Class library for my own project that throws Access violation.
.Net Core Console App for the test sample that throws a Stack Overflow
Platform: Any CPU
Target framework: .Net Core 3.1

Handlebars info:
Handlebars.Net v1.11.5 taken from NuGet
Publish date Saturday, October 10, 2020 (10/10/2020)

Visual studio info:
Microsoft Visual Studio Community 2019
Version 16.7.7
VisualStudio.16.Release/16.7.7+30621.155
Microsoft .NET Framework
Version 4.8.03752

C# Tools 3.7.0-6.20514.1+600c0dadd199296df3ed07dfabdc014563a77f7c
Debugging Tools for Windows 10.0.18346.1000
NuGet Package Manager 5.7.0

.Net system info:
Cmd Command: dotnet --info
SDK de .NET Core (reflejando cualquier global.json):
Version: 3.1.403
Commit: 9e895200cd

Entorno de tiempo de ejecución:
OS Name: Windows
OS Version: 10.0.18363
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.403\

Host (useful for support):
Version: 3.1.9
Commit: 774fc3d6a9

.NET Core SDKs installed:
2.1.511 [C:\Program Files\dotnet\sdk]
2.1.512 [C:\Program Files\dotnet\sdk]
2.1.519 [C:\Program Files\dotnet\sdk]
3.1.403 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other system info:
Microsoft Windows 10 Pro (10.0.18363 compilación 18363)
HP ProBook 440 G6, x64
Processor Intel(R) Core(TM) i7-8565U CPU

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions