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

Dict Equality Checks rapidly exceeds max recursion #684

Open
joe-kimmel-vmw opened this issue Jun 7, 2022 · 4 comments
Open

Dict Equality Checks rapidly exceeds max recursion #684

joe-kimmel-vmw opened this issue Jun 7, 2022 · 4 comments
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution enhancement This issue is a feature request

Comments

@joe-kimmel-vmw
Copy link
Contributor

What steps did you take:
I wanted to compare two (yaml) structures that had been read into data.values and turned into dictionaries.
I used the == operator as is our traditional way.

What happened:
- comparison exceeded maximum recursion depth

What did you expect:
a boolean

Anything else you would like to add:
the culprit is here: https://github.com/vmware-tanzu/carvel-ytt/blob/develop/vendor/github.com/k14s/starlark-go/starlark/value.go#L1134
because whenever they made starlark they were really conservative re. the stack limits for equality comparisons.

IMO this would be magical to expose via command line flag and/or hardcode several orders of magnitude larger.

(note that if this is exposed via CLI flag, I think there's another place where depth/maxdepth is also hardcoded, but I'll let you-all grep the codebase and consider implementation details like if i'm raising the recursion limit in one place do i probably also want to raise it in all the places? probably?)

Environment:
Here is a repro:

#@ def buildNest(mm, d):
#@ if d == 0:
#@   return mm
#@ end
#@ 
#! "i pity d foo"; see below
#@ i = d
#@ mm[d] = {i: buildNest({'pity': 'foo'}, d-1)}
#@ return mm
#@ end

#@ depth = 4

#@ map1 = buildNest({}, depth)
#@ map2 = buildNest({}, depth)

map: #@ map1
#! this exceeds recursion depth when depth >= 5. I pity d foo who exceeds max recursion depth!
nested_map: #@ map1 == map2

(i suspect this exists in all versions of ytt released up til today)


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@joe-kimmel-vmw joe-kimmel-vmw added bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Jun 7, 2022
@pivotaljohn
Copy link
Contributor

Related upstream: google/starlark-go#360

@pivotaljohn
Copy link
Contributor

Until recently, Starlark as a language operated (and through many integrations) under this comparison limit.

Hypotheses:

  • given that Starlark is meant to be used as a configuration language, this domain — in practice — does not need such depth.
  • folks ran into this limit and opted-out of using Starlark
  • ???

What brought this up, @joe-kimmel-vmw?

@pivotaljohn pivotaljohn added enhancement This issue is a feature request discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution and removed bug This issue describes a defect or unexpected behavior carvel triage This issue has not yet been triaged for relevance labels Jun 8, 2022
@pivotaljohn
Copy link
Contributor

This is Starlark behaving as designed: limit depth to avoid "infinite recursion". Increasing or making this limit greater is more of an enhancement than a bug. 🤷🏻

@aaronshurley aaronshurley moved this to To Triage in Carvel Aug 18, 2022
@pivotaljohn
Copy link
Contributor

Update: as part of #593, the required upstream support for setting this value (noted above) will be coming in to the next release of our Starlark fork. 🥳

@github-project-automation github-project-automation bot moved this to To Triage in Carvel Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution enhancement This issue is a feature request
Projects
Status: To Triage
Development

No branches or pull requests

2 participants