Skip to content
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

Avoid stack overflow in sourcetype.IsSourceType. #322

Merged

Conversation

mlevesquedion
Copy link
Contributor

Fixes #320.

In my understanding, a stack overflow can occur whenever we have a value of a type that is self-referential. Not all self-referential types are allowed by the compiler, e.g. type A A (which is nonsensical) is not allowed, but type A map[string]A is allowed (consider a tree-like type).

This PR adds a map[types.Type]bool of seen types to the type traversal to handle any cyclical types.

While testing this PR, I discovered a similar issue in utils.Dereference, which leads to an infinite loop: #321.

  • Running against a large codebase such as Kubernetes does not error out. (See DEVELOPING.md for instructions on how to do that.)
  • (N/A) Appropriate changes to README are included in PR

@mlevesquedion mlevesquedion force-pushed the avoid-sourcetype-stack-overflow branch from 8edc7b2 to 80fd612 Compare July 12, 2021 14:16
@mlevesquedion mlevesquedion force-pushed the avoid-sourcetype-stack-overflow branch from 1979b67 to 84e6b31 Compare July 13, 2021 13:26
@mlevesquedion mlevesquedion merged commit 99e3a7f into google:master Jul 13, 2021
@mlevesquedion mlevesquedion deleted the avoid-sourcetype-stack-overflow branch July 13, 2021 13:31
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.

Stack Overflow in internal/pkg/sourcetype/sourcetype.go
2 participants