Skip to content

[lsp] panic with slice bounds out of range [:-1] when typing anything in a source file #1691

@joshcartme

Description

@joshcartme

This looks similar to #1677, but the exact panic is different

Stack trace

======== Cache Statistics ========
[09:28:47.585] Open file count: 1
[09:28:47.585] Cached disk files: 48375
[09:28:47.585] Project count: 1
[09:28:47.585] Config count: 14
[09:28:47.585] Parse cache size: 47382
[09:28:47.585] Program count: 1
[09:28:47.585] Extended config cache size: 4

panic handling request textDocument/completion runtime error: slice bounds out of range [:-1] goroutine 458340 [running]:
runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
[github.com/microsoft/typescript-go/internal/lsp.(*Server).recover(](http://github.com/microsoft/typescript-go/internal/lsp.(*Server).recover()0x14000178dc0, 0x140df2dd440)
[github.com/microsoft/typescript-go/internal/lsp/server.go](http://github.com/microsoft/typescript-go/internal/lsp/server.go):532 +0x44
panic({0x103421a60?, 0x1405d30da10?})
runtime/panic.go:783 +0x120
[github.com/microsoft/typescript-go/internal/ls.(*exportInfoMap).add(](http://github.com/microsoft/typescript-go/internal/ls.(*exportInfoMap).add()0x141e557f078, {0x140071d30a0, 0x68}, 0x141461f8808, {0x103168090, 0x7}, 0x14145f69180, 0x140b3b922c8, 0x1, 0x0, ...)
[github.com/microsoft/typescript-go/internal/ls/autoimports.go](http://github.com/microsoft/typescript-go/internal/ls/autoimports.go):120 +0x800
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService)](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService)).searchExportInfosForCompletions.func3(0x14145f69180, 0x140b3b922c8, 0x140a820b308, 0x0)
[github.com/microsoft/typescript-go/internal/ls/autoimportsexportinfo.go](http://github.com/microsoft/typescript-go/internal/ls/autoimportsexportinfo.go):138 +0x148
[github.com/microsoft/typescript-go/internal/ls](http://github.com/microsoft/typescript-go/internal/ls).forEachExternalModuleToImportFrom.func1(0x10339a2c0?, 0x140df4b5b60?)
[github.com/microsoft/typescript-go/internal/ls/autoimports.go](http://github.com/microsoft/typescript-go/internal/ls/autoimports.go):1344 +0x28
[github.com/microsoft/typescript-go/internal/ls.forEachExternalModule(](http://github.com/microsoft/typescript-go/internal/ls.forEachExternalModule()0x140a820b308, {0x141e3d1e000, 0xb916, 0x10308eca4?}, 0x141e557edd0)
[github.com/microsoft/typescript-go/internal/ls/autoimports.go](http://github.com/microsoft/typescript-go/internal/ls/autoimports.go):1380 +0x12c
[github.com/microsoft/typescript-go/internal/ls.forEachExternalModuleToImportFrom(](http://github.com/microsoft/typescript-go/internal/ls.forEachExternalModuleToImportFrom()0x1400003ae28?, 0x102fa97ec?, 0x140a820ba88?, 0x1400b5360e2?)
[github.com/microsoft/typescript-go/internal/ls/autoimports.go](http://github.com/microsoft/typescript-go/internal/ls/autoimports.go):1339 +0x44
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService).searchExportInfosForCompletions(](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService).searchExportInfosForCompletions()0x1410fac76e0, {0x1035632b0, 0x140aad2ac30}, 0x140a820b308, 0x14072a74848, 0x141e2842fc0, 0x0, 0x0, 0x0, {0x1418aeafd01, ...}, ...)
[github.com/microsoft/typescript-go/internal/ls/autoimportsexportinfo.go](http://github.com/microsoft/typescript-go/internal/ls/autoimportsexportinfo.go):124 +0x260
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService)](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService)).getCompletionData.func9()
[github.com/microsoft/typescript-go/internal/ls/completions.go](http://github.com/microsoft/typescript-go/internal/ls/completions.go):1269 +0x19c
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService)](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService)).getCompletionData.func17()
[github.com/microsoft/typescript-go/internal/ls/completions.go](http://github.com/microsoft/typescript-go/internal/ls/completions.go):1685 +0x52c
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService)](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService)).getCompletionData.func18(...)
[github.com/microsoft/typescript-go/internal/ls/completions.go](http://github.com/microsoft/typescript-go/internal/ls/completions.go):1712
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData(](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionData()0x1410fac76e0, {0x1035632b0, 0x140aad2ac30}, 0x140a820b308, 0x14072a74848, 0x205, 0x141e2842fc0)
[github.com/microsoft/typescript-go/internal/ls/completions.go](http://github.com/microsoft/typescript-go/internal/ls/completions.go):1740 +0x16c4
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition(](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService).getCompletionsAtPosition()0x1410fac76e0, {0x1035632b0, 0x140aad2ac30}, 0x14072a74848, 0x205, 0x0, 0x141e2842fc0, 0x14000280c60)
[github.com/microsoft/typescript-go/internal/ls/completions.go](http://github.com/microsoft/typescript-go/internal/ls/completions.go):397 +0x234
[github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion(](http://github.com/microsoft/typescript-go/internal/ls.(*LanguageService).ProvideCompletion()0x1410fac76e0, {0x1035632b0, 0x140aad2ac30}, {0x141e0a98540?, 0x141e28ee050?}, {0x1?, 0x0?}, 0x141e3abc7b0, 0x14000280c60, 0x141e2842fc0)
[github.com/microsoft/typescript-go/internal/ls/completions.go](http://github.com/microsoft/typescript-go/internal/ls/completions.go):48 +0xb0
[github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion(](http://github.com/microsoft/typescript-go/internal/lsp.(*Server).handleCompletion()0x140003501c0?, {0x1035632b0, 0x140aad2ac30}, 0x1410fac76e0, 0x140df2dd410)
[github.com/microsoft/typescript-go/internal/lsp/server.go](http://github.com/microsoft/typescript-go/internal/lsp/server.go):754 +0xe0
[github.com/microsoft/typescript-go/internal/lsp](http://github.com/microsoft/typescript-go/internal/lsp).init.func1.registerLanguageServiceDocumentRequestHandler[...].15({0x1035632b0, 0x140aad2ac30}, 0x140df2dd440)
[github.com/microsoft/typescript-go/internal/lsp/server.go](http://github.com/microsoft/typescript-go/internal/lsp/server.go):518 +0xec
[github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(](http://github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification()0x14000178dc0, {0x1035632b0, 0x140aad2ac30}, 0x140df2dd440)
[github.com/microsoft/typescript-go/internal/lsp/server.go](http://github.com/microsoft/typescript-go/internal/lsp/server.go):424 +0xf4
[github.com/microsoft/typescript-go/internal/lsp.(*Server)](http://github.com/microsoft/typescript-go/internal/lsp.(*Server)).dispatchLoop.func1()
[github.com/microsoft/typescript-go/internal/lsp/server.go](http://github.com/microsoft/typescript-go/internal/lsp/server.go):329 +0x34
created by [github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop](http://github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop) in goroutine 21
[github.com/microsoft/typescript-go/internal/lsp/server.go](http://github.com/microsoft/typescript-go/internal/lsp/server.go):349 +0x6f8

Steps to reproduce

  1. Type anything in a typescript file

So far I've been unsuccessful reproducing this outside of our massive mono-repo but will definitely update this if I get a repro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions