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

fix stack overflow error #7114

Merged
merged 4 commits into from Dec 2, 2019
Merged

fix stack overflow error #7114

merged 4 commits into from Dec 2, 2019

Conversation

@zwwhdls
Copy link
Contributor

zwwhdls commented Nov 29, 2019

fix #7111

I found that when a circular reference existed in template "include" function, an endless loop happened in rendering until stack overflow.

My solution is recording the name which is included in a slice. Check the name when the next render comes, if it has been in the recorded slice, throw an error. If not, execute template and pop it out.

@helm-bot helm-bot added the size/XS label Nov 29, 2019
fixed #7111
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
@zwwhdls zwwhdls force-pushed the zwwhdls:fix7111 branch from 20d0a6e to a6bd2c7 Nov 29, 2019

// Add the 'include' function here so we can close over t.
funcMap["include"] = func(name string, data interface{}) (string, error) {
var buf strings.Builder
for _, n := range includedNames {
if n == name {
return "", errors.Wrapf(fmt.Errorf("unable to excute template"), "rendering template in a loop, name: %s", name)

This comment has been minimized.

Copy link
@grissomsh

grissomsh Nov 29, 2019

How about to use following error message - "rendering template has a nested reference name: %s" ?

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
@zwwhdls zwwhdls force-pushed the zwwhdls:fix7111 branch from d7031ff to a5d483a Nov 29, 2019
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
@helm-bot helm-bot added size/S and removed size/XS labels Nov 30, 2019
Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
Copy link
Contributor

hickeyma left a comment

@zwwhdls LGTM, thanks for this check.

@hickeyma hickeyma merged commit 750b870 into helm:master Dec 2, 2019
2 checks passed
2 checks passed
DCO DCO
Details
ci/circleci: build Your tests passed on CircleCI!
Details
@zwwhdls zwwhdls deleted the zwwhdls:fix7111 branch Dec 3, 2019
@hickeyma hickeyma added this to the 3.0.1 milestone Dec 4, 2019
@hickeyma hickeyma added v3.x bug labels Dec 4, 2019
jmcelwain added a commit to jmcelwain/helm that referenced this pull request Dec 5, 2019
* fixed helm#7111

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* update error message

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* add test case

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* fix lint error

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
jmcelwain added a commit to jmcelwain/helm that referenced this pull request Dec 5, 2019
* fixed helm#7111

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* update error message

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* add test case

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* fix lint error

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
mattfarina added a commit that referenced this pull request Dec 5, 2019
* fixed #7111

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* update error message

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* add test case

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>

* fix lint error

Signed-off-by: zwwhdls <zwwhdls@hotmail.com>
(cherry picked from commit 750b870)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.