-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve stack overflow stack trace pretty print #122243
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
Open
janvorli
wants to merge
2
commits into
dotnet:main
Choose a base branch
from
janvorli:improve-stack-overflow-pretty-print
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+65
−42
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a quadratic algorithm. What's the worst-case delay that it can lead to in real-world apps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there are
O(N log N)algorithms to do this if this one is too slow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am aware of the fact it is quadratic. I was also thinking of an option of setting a fixed limit to the outer loop so that in case we don't find a repeated sequence in that number of attempts (which would mean that there is no repeated sequence starting within that number of topmost frames), we would give up and show the whole stack.
As for the worst case delay, I've tried to run it with the repro you have shared in the #118218 and disabling the check for found repetition. That effectively simulates the worst case. Release build of your repro with tight loop has stack with 27084 frames at the time of the stack overflow and the time it took to run the full quadratic number of iterations was 0.16s on my Windows x64 machine with Release build of the runtime and release build of the test.
So given this result, I think it is 1ok to leave the quadratic algorithm in. If we wanted to be super safe, we could possibly add some high fixed limit of say ~1000 repetitions of the outer loop.