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

Crash during completion in front of non-empty [ ] #1606

Closed
1 task
radeksimko opened this issue Feb 5, 2024 · 2 comments · Fixed by hashicorp/hcl-lang#373
Closed
1 task

Crash during completion in front of non-empty [ ] #1606

radeksimko opened this issue Feb 5, 2024 · 2 comments · Fixed by hashicorp/hcl-lang#373
Labels
bug Something isn't working

Comments

@radeksimko
Copy link
Member

Language Server Version

v0.32.6

Terraform Version

Terraform v1.7.0

Client Version

VS Code Terraform extension 2.29.3

Terraform Configuration

output "example" {
  value = t [x]
}

Steps to Reproduce

  1. Trigger completion after t in the attached config
  2. Observe crash

Expected Behavior

No crash

Actual Behavior

Crash:

panic: runtime error: slice bounds out of range [:-2]

goroutine 51 [running]:
github.com/hashicorp/hcl-lang/decoder.functionExpr.CompletionAtPos({{0x103d112d0, 0x14000496780}, {{0x103d10e70, 0x1400000e311}}, 0x14000496000}, {0x103d10b98, 0x140004e76e0}, {0x0?, 0x0?, 0x14000496000?})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expr_function.go:56 +0x10a8
github.com/hashicorp/hcl-lang/decoder.Any.completeNonComplexExprAtPos({{0x103d112d0, 0x14000496780}, {{{0x103d10e70, 0x1400000e311}}, 0x0}, 0x14000496000}, {0x103d10b98, 0x140004e76e0}, {0x0?, 0x0?, ...})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expr_any_completion.go:136 +0x3e0
github.com/hashicorp/hcl-lang/decoder.Any.CompletionAtPos({{0x103d112d0, 0x14000496780}, {{{0x103d10e70, 0x1400000e311}}, 0x0}, 0x14000496000}, {0x103d10b98?, 0x140004e76e0?}, {0x103c12480?, 0x1400048fee0?, ...})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expr_any_completion.go:96 +0x4b4
github.com/hashicorp/hcl-lang/decoder.Any.completeIndexExprAtPos({{0x103d111f0, 0x1400033a7e0}, {{{0x103d11340, 0x104188f60}}, 0x0}, 0x14000496000}, {0x103d10b98, 0x140004e76e0}, {0x0?, 0x14000496000?, ...})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expr_any_index.go:45 +0x2c0
github.com/hashicorp/hcl-lang/decoder.Any.completeNonComplexExprAtPos({{0x103d111f0, 0x1400033a7e0}, {{{0x103d11340, 0x104188f60}}, 0x0}, 0x14000496000}, {0x103d10b98, 0x140004e76e0}, {0x1400057a848?, 0x10293c5cc?, ...})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expr_any_completion.go:148 +0x5a8
github.com/hashicorp/hcl-lang/decoder.Any.CompletionAtPos({{0x103d111f0, 0x1400033a7e0}, {{{0x103d11340, 0x104188f60}}, 0x0}, 0x14000496000}, {0x103d10b98?, 0x140004e76e0?}, {0x1c?, 0xc?, ...})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expr_any_completion.go:96 +0x4b4
github.com/hashicorp/hcl-lang/decoder.(*PathDecoder).attrValueCompletionAtPos(0x1400031a000, {0x103d10b98, 0x140004e76e0}, 0x5?, 0x1400031a120, {{0x140004a007e, 0x7}, {0x1, 0x10, 0xf}, ...}, ...)
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/expression_candidates.go:31 +0x1c8
github.com/hashicorp/hcl-lang/decoder.(*PathDecoder).completionAtPos(0x103c4d0a0?, {0x103d10b98, 0x140004e76e0}, 0x140004800b0, {{0x140004a007e, 0x7}, {0x1, 0x10, 0xf}, {0x3, ...}}, ...)
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/candidates.go:69 +0x830
github.com/hashicorp/hcl-lang/decoder.(*PathDecoder).completionAtPos(0x103d10b98?, {0x103d10b98, 0x140004e76e0}, 0x14000480160, {{0x140004a007e, 0x7}, {0x1, 0x10, 0xf}, {0x3, ...}}, ...)
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/candidates.go:147 +0x159c
github.com/hashicorp/hcl-lang/decoder.(*PathDecoder).CompletionAtPos(0x1400031a000, {0x103d10b98, 0x1400024a270}, {0x140004a007e, 0x7}, {0x101?, 0x140000ebea0?, 0x140000ebe9e?})
	github.com/hashicorp/hcl-lang@v0.0.0-20240122101040-f43c27231c10/decoder/candidates.go:47 +0x230
github.com/hashicorp/terraform-ls/internal/langserver/handlers.(*service).TextDocumentComplete(0x14000000ea0, {0x103d10b98, 0x1400024a270}, {{0x1, {0x0, 0x0}}, {{{0x140006b2570, 0x25}}, {0x1, 0xb}}, ...})
	github.com/hashicorp/terraform-ls/internal/langserver/handlers/complete.go:46 +0x2b4
reflect.Value.call({0x103c4a100?, 0x1400048e0a0?, 0x30?}, {0x102f34c64, 0x4}, {0x1400024ae40, 0x2, 0x102f1692c?})
	reflect/value.go:596 +0x994
reflect.Value.Call({0x103c4a100?, 0x1400048e0a0?, 0x103cbeae0?}, {0x1400024ae40?, 0x103c95d80?, 0x140004e2000?})
	reflect/value.go:380 +0x94
github.com/creachadair/jrpc2/handler.(*FuncInfo).Wrap.func8({0x103d10b98?, 0x1400024a270?}, 0x103c3eb80?)
	github.com/creachadair/jrpc2@v1.1.2/handler/handler.go:230 +0xd8
github.com/hashicorp/terraform-ls/internal/langserver/handlers.handle({0x103d10b98, 0x1400024a180}, 0x140004e2000, {0x103c4a100, 0x1400048e0a0})
	github.com/hashicorp/terraform-ls/internal/langserver/handlers/service.go:651 +0x47c
github.com/hashicorp/terraform-ls/internal/langserver/handlers.(*service).Assigner.func10({0x103d10b98?, 0x1400024a120?}, 0x1400024a120?)
	github.com/hashicorp/terraform-ls/internal/langserver/handlers/service.go:231 +0x130
github.com/creachadair/jrpc2.(*Server).invoke(0x1400014c600, {0x103d10bd0?, 0x140000a8280?}, 0x1400027de90, 0x140004e2000)
	github.com/creachadair/jrpc2@v1.1.2/server.go:387 +0xf4
github.com/creachadair/jrpc2.(*Server).dispatchLocked.func1()
	github.com/creachadair/jrpc2@v1.1.2/server.go:259 +0x158
github.com/creachadair/jrpc2.(*Server).serve.func1()
	github.com/creachadair/jrpc2@v1.1.2/server.go:180 +0x58
created by github.com/creachadair/jrpc2.(*Server).serve in goroutine 9
	github.com/creachadair/jrpc2@v1.1.2/server.go:178 +0x2c

Gist

No response

Workarounds

No response

References

No response

Help Wanted

  • I'm interested in contributing a fix myself

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
@dbanck
Copy link
Member

dbanck commented Feb 14, 2024

We just released a new version of the language server 0.32.7. This fixes the reported bug.

Thank you for the report @radeksimko

Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants