Skip to content

[Demangler] Prevent stack overflow by limiting recursion depth. #38192

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 1 commit into from
Jul 1, 2021

Conversation

al45tair
Copy link
Contributor

@al45tair al45tair commented Jul 1, 2021

It's trivially easy to drive the remanglers, the type decoder and the node printer into a situation where they will overflow the process's stack. For the compiler, this is fine (though not great), but for the runtime it's a no-no.

This changeset imposes recursion depth limits to prevent uncontrolled stack overruns.

rdar://68449341

@al45tair
Copy link
Contributor Author

al45tair commented Jul 1, 2021

@swift-ci Please smoke test

It's trivially easy to drive the remanglers, the type decoder and the node
printer into a situation where they will overflow the process's stack.  For the
compiler, this is fine (though not great), but for the runtime it's a no-no.

This changeset imposes recursion depth limits to prevent uncontrolled stack
overruns.

rdar://68449341
@al45tair al45tair force-pushed the problem/68449341 branch from 62d3d8d to 8f717d2 Compare July 1, 2021 10:12
@al45tair
Copy link
Contributor Author

al45tair commented Jul 1, 2021

@swift-ci Please smoke test

@al45tair al45tair requested a review from mikeash July 1, 2021 13:14
@al45tair al45tair merged commit 6d54625 into swiftlang:main Jul 1, 2021
@compnerd
Copy link
Member

compnerd commented Jul 2, 2021

@al45tair - this seems to have regressed the Windows builds as indicated by the CI

@al45tair
Copy link
Contributor Author

al45tair commented Jul 6, 2021

@compnerd Apologies. I should have spotted that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants