Skip to content

InsufficientExecutionStackException during model binding #6332

@martincostello

Description

@martincostello

Describe the bug

During a GET request to an MVC action, an exception of type InsufficientExecutionStackException was thrown.

Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.
System.InsufficientExecutionStackException: Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space.
   at void System.Runtime.CompilerServices.RuntimeHelpers.EnsureSufficientExecutionStack()
   at bool Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, string key, object model)
   at bool Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Validate(ModelMetadata metadata, string key, object model, bool alwaysValidateAtTopLevel)
   at void Microsoft.AspNetCore.Mvc.ModelBinding.ObjectModelValidator.Validate(ActionContext actionContext, ValidationStateDictionary validationState, string prefix, object model, ModelMetadata metadata)
   at void Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.EnforceBindRequiredAndValidate(ObjectModelValidator baseObjectValidator, ActionContext actionContext, ParameterDescriptor parameter, ModelMetadata metadata, ModelBindingContext modelBindingContext, ModelBindingResult modelBindingResult)
   at async Task<ModelBindingResult> Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, object value)
   at void Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider+<>c__DisplayClass0_0+<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
   at async Task Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at async Task Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()

The action is defined as thus:

[HttpGet]
[Route("{id}", Name = "MyRoute")]
[Produces("application/json", Type = typeof(MyViewModel))]
[ProducesResponseType(typeof(MyViewModel), StatusCodes.Status200OK)]
[ServiceFilter(typeof(IdValidationFilterAttribute))]
public async Task<ActionResult<MyViewModel>> Index(string id, CancellationToken cancellationToken = default)
{
    //
}

This issue looks similar to aspnet/Mvc#7357.

To Reproduce

Unknown, occurred during a normal GET request to a JSON resource in an ASP.NET MVC 2.2.0 application.

Expected behavior

Request succeeds.

Additional context

Application uses ASP.NET Core 2.2.0 and in-process IIS hosting.

Metadata

Metadata

Assignees

Labels

ExternalThis is an issue in a component not contained in this repository. It is open for tracking purposes.area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions