Skip to content

Remove stack overflow in EndpointFilterInvocationContexts #49285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 28, 2023

Conversation

slang25
Copy link
Contributor

@slang25 slang25 commented Jul 10, 2023

Remove potential stack overflow in EndpointFilterInvocationContexts

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Description

This change replaces the infinite recursive behaviour of the properties on the EndpointFilterInvocationContext types, and implement the Contains and IndexOf method explicitly instead.

Fixes #49284

@ghost ghost added area-runtime community-contribution Indicates that the PR has been added by a community member labels Jul 10, 2023
@ghost
Copy link

ghost commented Jul 10, 2023

Thanks for your PR, @slang25. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@davidfowl
Copy link
Member

Why not implement these instead?

@slang25
Copy link
Contributor Author

slang25 commented Jul 10, 2023

Why not implement these instead?

Good point, I've just pushed an implementation 👍

@slang25 slang25 changed the title Remove potential stack overflow in EndpointFilterInvocationContexts Remove stack overflow in EndpointFilterInvocationContexts Jul 10, 2023
@adityamandaleeka
Copy link
Member

@slang25 There's a whitespace mismatch that's causing a test to fail. Looks like you cleaned up some stray spaces on an empty line which it's not happy about 😆.

 Microsoft.AspNetCore.Http.Abstractions.Tests.EndpointFilterInvocationContextOfTTests.GeneratedCodeIsUpToDate [FAIL]
2023-07-10T10:14:57.7566156Z [xUnit.net 00:00:05.90]       Assert.Equal() Failure
2023-07-10T10:14:57.7592174Z [xUnit.net 00:00:05.90]                                          ↓ (pos 1189)
2023-07-10T10:14:57.7618665Z [xUnit.net 00:00:05.91]       Expected: ···Arg0 { get; set; }\r\n\r\n    public int Count => 1;\r\n\r\n    publi···
2023-07-10T10:14:57.7645943Z [xUnit.net 00:00:05.91]       Actual:   ···Arg0 { get; set; }\r\n    \r\n    public int Count => 1;\r\n\r\n    p···
2023-07-10T10:14:57.7673019Z [xUnit.net 00:00:05.91]                                          ↑ (pos 1189)
2023-07-10T10:14:57.7704214Z [xUnit.net 00:00:05.92]       Stack Trace:
2023-07-10T10:14:57.7735788Z [xUnit.net 00:00:05.92]         /_/src/Http/Http.Abstractions/test/EndpointFilterInvocationContextOfTTests.cs(96,0): at Microsoft.AspNetCore.Http.Abstractions.Tests.EndpointFilterInvocationContextOfTTests.GeneratedCodeIsUpToDate()

Comment on lines +55 to +56
<# foreach (var argumentCount in Enumerable.Range(0, arity)) { #> public T<#=argumentCount#> Arg<#=argumentCount#> { get; set; }
<# } #>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to explain this change, I'm on macOS and using either Rider or VSCode the editors immediately delete the whitespace from the generated files the moment I touch them, so this change makes editing them by hand less volatile.

Why am I editing the generated code by hand? Because when I try to use the tt generator it completely re-writes the file in a way that creates a massive diff (the header text is different for example).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth at some point having the repo updated to use the .NET 6 version of the tt generator - maybe that'll remove some of the xplat wonk (after an initial normalisation).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good recommendation! Mind filing an issue for this in case we're able to get around to it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@slang25
Copy link
Contributor Author

slang25 commented Jul 12, 2023

Thanks for your help @adityamandaleeka, I totally missed that.

@ghost
Copy link

ghost commented Jul 21, 2023

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@ghost ghost added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Jul 21, 2023
@slang25
Copy link
Contributor Author

slang25 commented Jul 21, 2023

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 49285 in repo dotnet/aspnetcore

@slang25
Copy link
Contributor Author

slang25 commented Jul 21, 2023

close & open to trigger to re-run validation

@slang25 slang25 closed this Jul 21, 2023
@slang25 slang25 reopened this Jul 21, 2023
@captainsafia
Copy link
Member

/azp run

@ghost ghost removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Jul 28, 2023
@azure-pipelines
Copy link

No commit pushedDate could be found for PR 49285 in repo dotnet/aspnetcore

@captainsafia captainsafia merged commit 8a6aaf2 into dotnet:main Jul 28, 2023
@ghost ghost added this to the 8.0-rc1 milestone Jul 28, 2023
@slang25 slang25 deleted the remove-stackoverflow branch July 28, 2023 19:40
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stack Overflow when using some EndpointFilterInvocationContext properties
6 participants