terratag icon indicating copy to clipboard operation
terratag copied to clipboard

Consider running tests with -race flag

Open TomerHeber opened this issue 3 years ago • 1 comments

This is a follow-up to #143. Issues were discovered when running tests with this flag. It may be a good idea to enable this flag to detect race conditions. However, at the moment there seems to be an issue when using this flag.

WARNING: DATA RACE
Write at 0x00000279f420 by goroutine 126:
  github.com/hashicorp/hcl/v2/hclwrite.formatSpaces()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/format.go:127 +0x29d
  github.com/hashicorp/hcl/v2/hclwrite.format()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/format.go:36 +0x6c
  github.com/hashicorp/hcl/v2/hclwrite.TokensForValue()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/generate.go:25 +0x8a
  github.com/hashicorp/hcl/v2/hclwrite.NewExpressionLiteral()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/ast_expression.go:61 +0x97
  github.com/hashicorp/hcl/v2/hclwrite.(*Body).SetAttributeValue()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/ast_body.go:167 +0x23d
  github.com/env0/terratag/internal/convert.AppendTagBlocks()
      /Users/theber/code/terratag/internal/convert/convert.go:153 +0x93a
  github.com/env0/terratag/internal/tagging.tagAutoscalingGroup()
      /Users/theber/code/terratag/internal/tagging/aws.go:9 +0x38
  github.com/env0/terratag/internal/tagging.TagResource()
      /Users/theber/code/terratag/internal/tagging/tagging.go:67 +0x157
  github.com/env0/terratag.tagFileResources()
      /Users/theber/code/terratag/terratag.go:147 +0xba4
  github.com/env0/terratag.tagDirectoryResources.func1()
      /Users/theber/code/terratag/terratag.go:86 +0x1e4
  github.com/env0/terratag.tagDirectoryResources.func2()
      /Users/theber/code/terratag/terratag.go:93 +0x58

Previous write at 0x00000279f420 by goroutine 100:
  github.com/hashicorp/hcl/v2/hclwrite.formatSpaces()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/format.go:127 +0x29d
  github.com/hashicorp/hcl/v2/hclwrite.format()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/format.go:36 +0x6c
  github.com/hashicorp/hcl/v2/hclwrite.TokensForValue()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/generate.go:25 +0x8a
  github.com/hashicorp/hcl/v2/hclwrite.NewExpressionLiteral()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/ast_expression.go:61 +0x97
  github.com/hashicorp/hcl/v2/hclwrite.(*Body).SetAttributeValue()
      /Users/theber/go/pkg/mod/github.com/hashicorp/hcl/[email protected]/hclwrite/ast_body.go:167 +0x23d
  github.com/env0/terratag/internal/convert.AppendLocalsBlock()
      /Users/theber/code/terratag/internal/convert/convert.go:141 +0xd9b
  github.com/env0/terratag.tagFileResources()
      /Users/theber/code/terratag/terratag.go:185 +0xdbd
  github.com/env0/terratag.tagDirectoryResources.func1()
      /Users/theber/code/terratag/terratag.go:86 +0x1e4
  github.com/env0/terratag.tagDirectoryResources.func2()
      /Users/theber/code/terratag/terratag.go:93 +0x58

I have reached out to HCL about this issue. https://github.com/hashicorp/hcl/issues/533

TomerHeber avatar Jun 06 '22 15:06 TomerHeber

The issue has been fixed in HCL. The next release should contain the fix.

TomerHeber avatar Jun 14 '22 01:06 TomerHeber

@TomerHeber I'm closing this one, feel free to re-open if you find it still relevant.

yaronya avatar Oct 13 '22 05:10 yaronya