aspnetcore: InsufficientExecutionStackException during model binding
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (12 by maintainers)
That’s super weird. The error from https://github.com/aspnet/Mvc/issues/7357 is fairly consistent for a given model type and neither of the two parameter types from your action fit the bill. I’ll go over the code once over to see we don’t have any latent caching bugs in our code that might produce this exception.