Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

Splat evaluation is not concurrency-safe #28

Closed
apparentlymart opened this issue May 22, 2018 · 0 comments
Closed

Splat evaluation is not concurrency-safe #28

apparentlymart opened this issue May 22, 2018 · 0 comments
Labels

Comments

@apparentlymart
Copy link
Contributor

apparentlymart commented May 22, 2018

Splat expressions require some odd gymnastics to evaluate, since they are similar to a for expression but with an anonymous iterator symbol.

That anonymous iterator is handled internally via a special expression node type whose value changes dynamically (per EvalContext) during evaluation. Due to how the internals work here, the current implementation cannot safely support concurrent evaluation of the same splat expression from two callers with separate EvalContexts: a map is modified concurrently, which can cause a crash.

As a general rule HCL is not expected to be concurrency-safe in most cases -- that's the caller's responsibility -- but for splat expressions in particular this implementation detail is pretty hard for the caller to properly manage, so we should make an exception here and make AnonSymbolExpr (the expression node that represents the anonymous iterator) use a mutex to allow concurrent evaluations of the same splat expression.

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

No branches or pull requests

1 participant