Skip to content

Nil pointer derefence in (*NodeBuilderImpl).addPropertyToElementList with --tsBuildInfoFile #3357

@LukeAbby

Description

@LukeAbby

Stack trace

panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x884049]

goroutine 14712 [running]:
sync.(*WaitGroup).Go.func1.1()
        sync/waitgroup.go:251 +0x45
panic({0xd17120?, 0x1ac2140?})
        runtime/panic.go:860 +0x13a
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).addPropertyToElementList(0x18b69e8fc80, 0x18b6d313048, {0x18b6a2386a0, 0x4, 0x4})
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2321 +0x9e9
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).createTypeNodesFromResolvedType(0x18b69e8fc80, 0x18b58f07200)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2471 +0x710
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).createTypeNodeFromObjectType(0x18b69e8fc80, 0x18b58f07200)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2532 +0x2a7
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).visitAndTransformType(0x18b69e8fc80, 0x18b58f07200, 0x10d5588)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2910 +0x4d8
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).createAnonymousTypeNode(0x18b69e8fc80, 0x18b58f07200)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2625 +0x397
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).typeReferenceToTypeNode(0x18b69e8fc80, 0x18b58f07200)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2793 +0x1d7
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).typeToTypeNode(0x18b69e8fc80, 0x1b1eea0?)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:3112 +0x985
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).mapToTypeNodes(0x18b69e8fc80, {0x18b6b38db80, 0x2, 0x18b6c19f140?}, 0x6c?)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:283 +0x4e5
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).typeReferenceToTypeNode(0x18b69e8fc80, 0x18b6b4907e0)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2850 +0xfba
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).typeToTypeNode(0x18b69e8fc80, 0x18b6a21d620?)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:3112 +0x985
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilderImpl).serializeTypeForDeclaration(0x18b69e8fc80, 0x18b54fdb188?, 0x800081c0d?, 0x10f22d8?, 0x1)
        github.com/microsoft/typescript-go/internal/checker/nodebuilderimpl.go:2108 +0x7cd
github.com/microsoft/typescript-go/internal/checker.(*NodeBuilder).SerializeTypeForDeclaration(0x18b6a2200f0, 0x18b558a5728, 0x18b63202e08, 0x412662?, 0x83f1c0?, 0x0?, {0x10f22d8?, 0x18b66a86e10?})
        github.com/microsoft/typescript-go/internal/checker/nodebuilder.go:97 +0x59
github.com/microsoft/typescript-go/internal/checker.(*EmitResolver).CreateTypeOfDeclaration(0x18b60529440, 0x18b66aa40a0, 0x18b558a5728, 0x18b54fdb188, 0x81c0d, 0x8, {0x10f22d8, 0x18b66a86e10})
        github.com/microsoft/typescript-go/internal/checker/emitresolver.go:925 +0x174
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).ensureType(0x18b60049dc0, 0x18b558a5728, 0x5?)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:1201 +0x28d
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).transformVariableDeclaration(0x18b60049dc0, 0x18b558a5728)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:756 +0x78
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).visitDeclarationSubtree(0x18b60049dc0, 0x18b558a5728)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:559 +0xe37
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).visit(0x18b60529490?, 0x10f0a80?)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:233 +0x116
github.com/microsoft/typescript-go/internal/ast.(*NodeVisitor).VisitSlice(0x18b5b3019e0, {0x18b54f22270, 0x1, 0x1})
        github.com/microsoft/typescript-go/internal/ast/visitor.go:148 +0xc2
github.com/microsoft/typescript-go/internal/ast.(*NodeVisitor).VisitNodes(0x18b5b3019e0, 0x18b55062300)
        github.com/microsoft/typescript-go/internal/ast/visitor.go:99 +0x37
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).transformVariableStatement(0x18b60049dc0, 0x18b55892410)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:1604 +0xed
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).transformTopLevelDeclaration(0x18b60049dc0, 0x18b55892410)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:1285 +0x359
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).visitDeclarationStatements(0x18b60049dc0, 0x18b55892410)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:1062 +0x8b3
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).visit(0x18b579eab48?, 0x83c9fa?)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:207 +0xfc
github.com/microsoft/typescript-go/internal/ast.(*NodeVisitor).VisitSlice(0x18b5b3019e0, {0x18b54fa4540, 0x8, 0x8})
        github.com/microsoft/typescript-go/internal/ast/visitor.go:148 +0xc2
github.com/microsoft/typescript-go/internal/ast.(*NodeVisitor).VisitNodes(0x18b5b3019e0, 0x18b55890480)
        github.com/microsoft/typescript-go/internal/ast/visitor.go:99 +0x37
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).transformSourceFile(0x18b60049dc0, 0x18b54fdb188)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:275 +0x3d
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).visitSourceFile(0x18b60049dc0, 0x18b54fdb188)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:262 +0x1a7
github.com/microsoft/typescript-go/internal/transformers/declarations.(*DeclarationTransformer).visit(0x18b5c67c0c0?, 0x3f?)
        github.com/microsoft/typescript-go/internal/transformers/declarations/transform.go:190 +0xe5
github.com/microsoft/typescript-go/internal/ast.(*NodeVisitor).VisitNode(0x18b6415c0d0?, 0x18b66aa40a0?)
        github.com/microsoft/typescript-go/internal/ast/visitor.go:51 +0x27
github.com/microsoft/typescript-go/internal/ast.(*NodeVisitor).VisitSourceFile(...)
        github.com/microsoft/typescript-go/internal/ast/visitor.go:36
github.com/microsoft/typescript-go/internal/transformers.(*Transformer).TransformSourceFile(...)
        github.com/microsoft/typescript-go/internal/transformers/transformer.go:40
github.com/microsoft/typescript-go/internal/compiler.(*emitter).emitDeclarationFile(0x18b6415c0d0, 0x18b54fdb188, {0x18b5c67c0c0, 0x3f}, {0x0, 0x0})
        github.com/microsoft/typescript-go/internal/compiler/emitter.go:202 +0x258
github.com/microsoft/typescript-go/internal/compiler.(*emitter).emit(0x18b6415c0d0)
        github.com/microsoft/typescript-go/internal/compiler/emitter.go:48 +0x5e
github.com/microsoft/typescript-go/internal/compiler.(*Program).Emit.func2()
        github.com/microsoft/typescript-go/internal/compiler/program.go:1587 +0x1b8
github.com/microsoft/typescript-go/internal/core.(*parallelWorkGroup).Queue.func1()
        github.com/microsoft/typescript-go/internal/core/workgroup.go:40 +0x13
sync.(*WaitGroup).Go.func1()
        sync/waitgroup.go:258 +0x4a
created by sync.(*WaitGroup).Go in goroutine 14292
        sync/waitgroup.go:238 +0x73

Steps to reproduce

  1. Run git clone https://github.com/League-of-Foundry-Developers/foundry-vtt-types
  2. Run cd foundry-vtt-types
  3. Run git checkout 2cc942d6f23d850a0012b0e48273c5269a3767a9
  4. Run npm ci
  5. (Optional) Run npm add -D @typescript/native-preview to get the latest TSGo version.
  6. Run npx tsgo --incremental. This will take a bit and NOT error.
  7. Run npx tsgo --incremental --tsBuildInfoFile tsconfig.tsbuildinfo -p ./tests/tsconfig.json. The tsconfig.tsbuildinfo file doesn't have to exist but the flag must be there.

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