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

provider/template: fix race causing panic in template_file #4694

Merged
merged 1 commit into from
Jan 16, 2016

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Jan 15, 2016

The render code path in template_file was doing unsynchronized access
to a shared mapping of functions in config.Func.

This caused a race condition that was most often triggered when a
template_file had a count of more than one, and expressed itself as
a panic in the plugin followed by a cascade of "unexpected EOF" errors
through the plugin system.

Here, we simply turn the FuncMap from shared state into a generated
value, which avoids the race. We do more re-initialization of the data
structure, but the performance implications are minimal, and we can
always revisit with a perf pass later now that the race is fixed.

The render code path in `template_file` was doing unsynchronized access
to a shared mapping of functions in `config.Func`.

This caused a race condition that was most often triggered when a
`template_file` had a `count` of more than one, and expressed itself as
a panic in the plugin followed by a cascade of "unexpected EOF" errors
through the plugin system.

Here, we simply turn the FuncMap from shared state into a generated
value, which avoids the race. We do more re-initialization of the data
structure, but the performance implications are minimal, and we can
always revisit with a perf pass later now that the race is fixed.
@phinze phinze mentioned this pull request Jan 15, 2016
@jen20
Copy link
Contributor

jen20 commented Jan 15, 2016

LGTM.

phinze added a commit that referenced this pull request Jan 16, 2016
provider/template: fix race causing panic in template_file
@phinze phinze merged commit 475c0c8 into master Jan 16, 2016
@phinze phinze deleted the phinze/template-func-race branch January 16, 2016 17:43
@ghost
Copy link

ghost commented Apr 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants