sourcegraph / lsif-go

Language Server Indexing Format (LSIF) generator for Go
https://lsif.dev/
MIT License
116 stars 20 forks source link

Removing CGO_ENABLED=0 causes a panic accessing documents #231

Closed chrismwendt closed 2 years ago

chrismwendt commented 2 years ago

On sourcegraph/sourcegraph/lib cd lib/ at 2d7f5b9a014a81a33df5812ede6f5cfa368b49ee

lsif-go f7ea2423e6b666886bd104c74379087028f0ec18 with the following patch:

diff --git a/internal/indexer/indexer.go b/internal/indexer/indexer.go
index 3546c8d..f0a3ef2 100644
--- a/internal/indexer/indexer.go
+++ b/internal/indexer/indexer.go
@@ -9,7 +9,6 @@ import (
    "go/types"
    "log"
    "math"
-   "os"
    "path"
    "strings"
    "sync"
@@ -279,7 +278,7 @@ func (i *Indexer) loadPackage(deduplicate bool, patterns ...string) ([]*packages

        // CGO_ENABLED=0 makes sure that we can handle files with assembly
        // and other problems that may occur (unsure of exact reasons at time of writing)
-       Env: append(os.Environ(), "CGO_ENABLED=0"),
+       // Env: append(os.Environ(), "CGO_ENABLED=0"),
    }

    // Make sure we only load packages once per execution.
✔ Resolving module name... Done
✔ Listing dependencies... Done
✔ Loading packages... Done
✔ Emitting documents... Done
⠦ Emitting import references and definitions... panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x1027d27f8]

goroutine 5105 [running]:
github.com/sourcegraph/lsif-go/internal/indexer.(*Indexer).emitImportMoniker(0x140001266c0, 0x566, 0x140007ecf00, {0x10296bd30, 0x14026c19560}, 0x0)
    /Users/chrismwendt/github.com/sourcegraph/lsif-go/internal/indexer/moniker.go:69 +0x1b8
github.com/sourcegraph/lsif-go/internal/indexer.(*Indexer).emitImportMonikerReference(0x140001266c0, 0x140007ecf00, 0x1400013d7c0, 0x140109982a0)
    /Users/chrismwendt/github.com/sourcegraph/lsif-go/internal/indexer/indexer.go:447 +0x220
github.com/sourcegraph/lsif-go/internal/indexer.(*Indexer).emitImportsForPackage(0x140001266c0, 0x140007ecf00)
    /Users/chrismwendt/github.com/sourcegraph/lsif-go/internal/indexer/indexer.go:416 +0x12c
github.com/sourcegraph/lsif-go/internal/indexer.(*Indexer).visitEachPackage.func1.1()
    /Users/chrismwendt/github.com/sourcegraph/lsif-go/internal/indexer/visit.go:65 +0xb4
github.com/sourcegraph/lsif-go/internal/parallel.Run.func1(0x1402655a1a0, 0x14026701080, 0x1402655a190)
    /Users/chrismwendt/github.com/sourcegraph/lsif-go/internal/parallel/parallel.go:24 +0x74
created by github.com/sourcegraph/lsif-go/internal/parallel.Run
    /Users/chrismwendt/github.com/sourcegraph/lsif-go/internal/parallel/parallel.go:20 +0x98