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

x/vuln: govulncheck seg faults when used against project using 1.22.0 #65590

Closed
elambert opened this issue Feb 8, 2024 · 24 comments
Closed

x/vuln: govulncheck seg faults when used against project using 1.22.0 #65590

elambert opened this issue Feb 8, 2024 · 24 comments
Assignees
Labels
vulncheck or vulndb Issues for the x/vuln or x/vulndb repo

Comments

@elambert
Copy link

elambert commented Feb 8, 2024

We have a go project that we build using go1.21.6. We've been using govulncheck to check the project for vulnerabilities.

Today, we upgraded from 1.21.6 to 1.22.0. Now when we run govulncheck we see a stack trace.

% govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v1.0.4
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC

No vulnerabilities found.
% govulncheck ./...
Scanning your code and 608 packages across 118 dependent modules for known vulnerabilities...

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x10115154c]

goroutine 9467 [running]:
golang.org/x/tools/go/ssa.memberFromObject(0x1403764dc00, {0x0, 0x0?}, {0x1013282a0, 0x1401ac69500}, {0x0, 0x0})
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:55 +0x3c
golang.org/x/tools/go/ssa.membersFromDecl(0x1403764dc00, {0x101329798?, 0x1401ac69500?}, {0x0, 0x0})
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:184 +0xf4
golang.org/x/tools/go/ssa.(*Program).CreatePackage(0x140108b1380, 0x1401ac6c900, {0x140193f8cb0, 0x1, 0x1}, 0x1401aaee230, 0x1)
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:250 +0x7e8
golang.org/x/vuln/internal/vulncheck.buildSSA.func1(0x0?)
	/Users/lambere/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/utils.go:38 +0xc0
golang.org/x/vuln/internal/vulncheck.buildSSA({0x140004f0600, 0x59, 0x14001380798?}, 0x14000158740)
	/Users/lambere/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/utils.go:46 +0x268
golang.org/x/vuln/internal/vulncheck.source.func1()
	/Users/lambere/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/source.go:54 +0x88
created by golang.org/x/vuln/internal/vulncheck.source in goroutine 35
	/Users/lambere/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/source.go:52 +0x204

If i down grade the project back to 1.21.6, govuln works as expected

% govulncheck -version
Go: go1.21.6
Scanner: govulncheck@v1.0.4
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC

No vulnerabilities found.
% govulncheck ./...
Scanning your code and 605 packages across 118 dependent modules for known vulnerabilities...

No vulnerabilities found.

Go version details

% go version
go version go1.22.0 darwin/arm64
@gopherbot gopherbot added the vulncheck or vulndb Issues for the x/vuln or x/vulndb repo label Feb 8, 2024
@gopherbot gopherbot modified the milestones: Unreleased, vuln/unplanned Feb 8, 2024
@Zxilly
Copy link
Contributor

Zxilly commented Feb 8, 2024

Try clone https://github.com/golang/vuln, bump the version of golang.org/x/tools to v0.17.1-0.20240207215834-5fcc6273f47e then rebuild it.

@elambert
Copy link
Author

elambert commented Feb 8, 2024

Thanks for looking into this.

Still seeing a seg fault

% ../vuln/cmd/govulncheck/govulncheck ./...
Scanning your code and 608 packages across 118 dependent modules for known vulnerabilities...

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x102c9d78c]

goroutine 9482 [running]:
golang.org/x/tools/go/ssa.memberFromObject(0x14034b5ca80, {0x0, 0x0?}, {0x102e74300, 0x14016daaf90}, {0x0, 0x0})
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.1-0.20240207215834-5fcc6273f47e/go/ssa/create.go:55 +0x3c
golang.org/x/tools/go/ssa.membersFromDecl(0x14034b5ca80, {0x102e75820?, 0x14016daaf90?}, {0x0, 0x0})
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.1-0.20240207215834-5fcc6273f47e/go/ssa/create.go:184 +0xf4
golang.org/x/tools/go/ssa.(*Program).CreatePackage(0x14008fa5c70, 0x14016da9f20, {0x140165f8960, 0x1, 0x1}, 0x14016dc2320, 0x1)
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.1-0.20240207215834-5fcc6273f47e/go/ssa/create.go:250 +0x7e8
golang.org/x/vuln/internal/vulncheck.buildSSA.func1(0x1400018aa20?)
	/Users/lambere/git/vuln/internal/vulncheck/utils.go:38 +0xc0
golang.org/x/vuln/internal/vulncheck.buildSSA({0x14028bee000, 0x59, 0x0?}, 0x1400007e940)
	/Users/lambere/git/vuln/internal/vulncheck/utils.go:46 +0x268
golang.org/x/vuln/internal/vulncheck.source.func1()
	/Users/lambere/git/vuln/internal/vulncheck/source.go:54 +0x88
created by golang.org/x/vuln/internal/vulncheck.source in goroutine 6
	/Users/lambere/git/vuln/internal/vulncheck/source.go:52 +0x204
% ../vuln/cmd/govulncheck/govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v0.0.0-5507063454b1-20240206192649
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC
% git rev-parse HEAD
5507063454b1b8c930db99818a88b52f1f143418
% git diff
diff --git a/go.mod b/go.mod
index 1e785be..a712287 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@ require (
        github.com/google/go-cmp v0.5.8
        golang.org/x/mod v0.14.0
        golang.org/x/sync v0.6.0
-       golang.org/x/tools v0.17.0
+       golang.org/x/tools v0.17.1-0.20240207215834-5fcc6273f47e
        mvdan.cc/unparam v0.0.0-20230312165513-e84e2d14e3b8
 )

diff --git a/go.sum b/go.sum
index 815313c..869e3d1 100644
--- a/go.sum
+++ b/go.sum
@@ -9,7 +9,7 @@ golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
 golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
 golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
 golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
-golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
-golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps=
+golang.org/x/tools v0.17.1-0.20240207215834-5fcc6273f47e h1:08FJDFVdwBsn3UF8mUh+vR3DphhU2WWxblaXSioh32o=
+golang.org/x/tools v0.17.1-0.20240207215834-5fcc6273f47e/go.mod h1:ngPhXSzq5toGRGmVELsotoOaTqvj1Ojf/H79cbjAGfw=
 mvdan.cc/unparam v0.0.0-20230312165513-e84e2d14e3b8 h1:VuJo4Mt0EVPychre4fNlDWDuE5AjXtPJpRUWqZDQhaI=
 mvdan.cc/unparam v0.0.0-20230312165513-e84e2d14e3b8/go.mod h1:Oh/d7dEtzsNHGOq1Cdv8aMm3KdKhVvPbRQcM8WFpBR8=

@zpavlinovic
Copy link
Contributor

It seems this is a bug in the ssa dependency. Could you provide steps to reproduce this?

@zpavlinovic zpavlinovic self-assigned this Feb 8, 2024
@elambert
Copy link
Author

elambert commented Feb 8, 2024

65590.zip
I can reproduce with a very simple go file and corresponding go.mod which are included in the attached 65590.zip zip file. To reproduce:

  • unzip the file
  • cd into 65590 directory
  • run govulncheck
% unzip ./65590.zip
Archive:  ./65590.zip
 extracting: 65590/go.mod
  inflating: 65590/main.go
% cd 65590
% ls
go.mod	main.go
% ~/git/vuln/cmd/govulncheck/govulncheck ./...
Scanning your code and 44 packages across 1 dependent module for known vulnerabilities...

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x100b2d78c]

goroutine 619 [running]:
golang.org/x/tools/go/ssa.memberFromObject(0x140033cfe00, {0x0, 0x0?}, {0x100d04300, 0x140075e6ea0}, {0x0, 0x0})
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.1-0.20240207215834-5fcc6273f47e/go/ssa/create.go:55 +0x3c
golang.org/x/tools/go/ssa.membersFromDecl(0x140033cfe00, {0x100d05820?, 0x140075e6ea0?}, {0x0, 0x0})
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.1-0.20240207215834-5fcc6273f47e/go/ssa/create.go:184 +0xf4
golang.org/x/tools/go/ssa.(*Program).CreatePackage(0x14004848000, 0x140064202a0, {0x140074db5b8, 0x1, 0x1}, 0x14002ce9040, 0x0)
	/Users/lambere/go/pkg/mod/golang.org/x/tools@v0.17.1-0.20240207215834-5fcc6273f47e/go/ssa/create.go:250 +0x7e8
golang.org/x/vuln/internal/vulncheck.buildSSA({0x140074db5d8, 0x1, 0x14000052798?}, 0x14000118280)
	/Users/lambere/git/vuln/internal/vulncheck/utils.go:54 +0x37c
golang.org/x/vuln/internal/vulncheck.source.func1()
	/Users/lambere/git/vuln/internal/vulncheck/source.go:54 +0x88
created by golang.org/x/vuln/internal/vulncheck.source in goroutine 6
	/Users/lambere/git/vuln/internal/vulncheck/source.go:52 +0x204
[65590.zip](https://github.com/golang/go/files/14213979/65590.zip)
% ~/git/vuln/cmd/govulncheck/govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v0.0.0-5507063454b1-20240206192649
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC

No vulnerabilities found.

Note, in the snippet above I used the version of govulncheck built with x/tools v0.17.1-0.20240207215834-5fcc6273f47e but I also see the same behavior with the 1.0.4 release.

I suspect this is something unique to my environment? Though I should point out that at least two other colleagues of mine have encountered this on their machines (one on Darwin/amd64 and the other on Darwin/arm64) Let me if there is more info you need.

@timothy-king
Copy link
Contributor

Possibly a duplicate of #65608 ?

@findleyr
Copy link
Contributor

findleyr commented Feb 8, 2024

Unfortunately that reproducer did not reproduce for me:

[roam:65590]> go install golang.org/x/vuln/cmd/govulncheck@latest
[roam:65590]> govulncheck ./...
Scanning your code and 45 packages across 1 dependent module for known vulnerabilities...

No vulnerabilities found.
[roam:65590]> go version
go version go1.22.0 linux/amd64

@elambert
Copy link
Author

elambert commented Feb 8, 2024

Unfortunately that reproducer did not reproduce for me:

[roam:65590]> go install golang.org/x/vuln/cmd/govulncheck@latest
[roam:65590]> govulncheck ./...
Scanning your code and 45 packages across 1 dependent module for known vulnerabilities...

No vulnerabilities found.
[roam:65590]> go version
go version go1.22.0 linux/amd64

Perhaps an environment issue on my machine .. here's my go env

% go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/lambere/Library/Caches/go-build'
GOENV='/Users/lambere/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/lambere/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/lambere/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/lambere/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/lambere/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/lambere/65590-steps/65590/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/5g/vcbxp4bn64v09lrd7cnrfy8h0000gp/T/go-build1218479303=/tmp/go-build -gno-record-gcc-switches -fno-common'

@andresvia
Copy link

I also have a darwin/arm64 and can reproduce the bug. When running with a linux container I can't reproduce, I can't say much about since I don't know much (nothing!) about ssa

this is fine

docker build --progress=plain --platform=linux/amd64 --file - . <<'EOF'
FROM golang:1.22.0
WORKDIR /65590
RUN echo 'module test' >  go.mod
RUN echo 'go 1.22.0'   >> go.mod
RUN echo 'package main'                 > main.go
RUN echo 'import "fmt"'                 >> main.go
RUN echo 'func main () {'               >> main.go
RUN echo '  fmt.Println("Hello World")' >> main.go
RUN echo '}'                            >> main.go
RUN go fmt ./...
RUN go run main.go
RUN go install -v golang.org/x/vuln/cmd/govulncheck@v1.0.4 
RUN govulncheck
RUN govulncheck ./...
EOF

this is also fine

docker build --progress=plain --platform=linux/arm64 --file - . <<'EOF'
FROM golang:1.22.0
WORKDIR /65590
RUN echo 'module test' >  go.mod
RUN echo 'go 1.22.0'   >> go.mod
RUN echo 'package main'                 > main.go
RUN echo 'import "fmt"'                 >> main.go
RUN echo 'func main () {'               >> main.go
RUN echo '  fmt.Println("Hello World")' >> main.go
RUN echo '}'                            >> main.go
RUN go fmt ./...
RUN go run main.go
RUN go install -v golang.org/x/vuln/cmd/govulncheck@v1.0.4 
RUN govulncheck
RUN govulncheck ./...
EOF

@H0llyW00dzZ
Copy link

this panic as well for me

$ govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v1.0.1
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC

No vulnerabilities found.

Share feedback at https://go.dev/s/govulncheck-feedback.
$ govulncheck ./...
Scanning your code and 386 packages across 30 dependent modules for known vulnerabilities...

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x5be12a]

goroutine 4517 [running]:
golang.org/x/tools/go/ssa.memberFromObject(0xc009efdf00, {0x0, 0x0?}, {0x0, 0x0})
        C:/Users/erian/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230815132531-74c255bcf846/go/ssa/create.go:53 +0x4a
golang.org/x/tools/go/ssa.membersFromDecl(0xc009efdf00, {0x795250?, 0xc00e25c380?})
        C:/Users/erian/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230815132531-74c255bcf846/go/ssa/create.go:141 +0x373
golang.org/x/tools/go/ssa.(*Program).CreatePackage(0xc02179a180, 0xc00b1d2660, {0xc009110540, 0x3, 0x3}, 0xc00e26a140, 0x1)
        C:/Users/erian/go/pkg/mod/golang.org/x/tools@v0.12.1-0.20230815132531-74c255bcf846/go/ssa/create.go:222 +0x77c
golang.org/x/vuln/internal/vulncheck.buildSSA.func1(0xc000232040?)
        C:/Users/erian/go/pkg/mod/golang.org/x/vuln@v1.0.1/internal/vulncheck/utils.go:37 +0xe5
golang.org/x/vuln/internal/vulncheck.buildSSA({0xc006062640, 0x7, 0xc0005e7f90?}, 0x293aa5?)
        C:/Users/erian/go/pkg/mod/golang.org/x/vuln@v1.0.1/internal/vulncheck/utils.go:45 +0x128
golang.org/x/vuln/internal/vulncheck.Source.func1()
        C:/Users/erian/go/pkg/mod/golang.org/x/vuln@v1.0.1/internal/vulncheck/source.go:63 +0x8f
created by golang.org/x/vuln/internal/vulncheck.Source in goroutine 6
        C:/Users/erian/go/pkg/mod/golang.org/x/vuln@v1.0.1/internal/vulncheck/source.go:61 +0x2d9

env:

$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\erian\AppData\Local\go-build
set GOENV=C:\Users\erian\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\erian\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\erian\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\h0llyw00dz\GoGenAI-Terminal-Chat\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\erian\AppData\Local\Temp\go-build2961088783=/tmp/go-build -gno-record-gcc-switches

@H0llyW00dzZ
Copy link

Latest version it fix

$ govulncheck ./...
Scanning your code and 386 packages across 32 dependent modules for known vulnerabilities...

No vulnerabilities found.
$ govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v1.0.4
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC

No vulnerabilities found.

@iwata
Copy link

iwata commented Feb 9, 2024

I'm using v1.0.4, but panicked.

$ govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v1.0.4
DB: https://vuln.go.dev
DB updated: 2024-02-07 04:19:28 +0000 UTC

No vulnerabilities found.
$ govulncheck ./...
Scanning your code and 1003 packages across 136 dependent modules for known vulnerabilities...

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x104bf17cc]

goroutine 15389 [running]:
golang.org/x/tools/go/ssa.memberFromObject(0x14065ba8f00, {0x0, 0x0?}, {0x0, 0x0}, {0x0, 0x0})
        /Users/iwata/.go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:55 +0x3c
golang.org/x/tools/go/ssa.membersFromDecl(0x14065ba8f00, {0x104dc9748?, 0x14049f1cac0?}, {0x0, 0x0})
        /Users/iwata/.go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:161 +0x3e4
golang.org/x/tools/go/ssa.(*Program).CreatePackage(0x1404d7e5860, 0x14049f24000, {0x140430f3c80, 0x1, 0x1}, 0x14049a76a50, 0x1)
        /Users/iwata/.go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:250 +0x7e8
golang.org/x/vuln/internal/vulncheck.buildSSA.func1(0x0?)
        /Users/iwata/.go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/utils.go:38 +0xc0
golang.org/x/vuln/internal/vulncheck.buildSSA({0x14046ce9800, 0x40, 0x14002b37f98?}, 0x140002bc080)
        /Users/iwata/.go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/utils.go:46 +0x268
golang.org/x/vuln/internal/vulncheck.source.func1()
        /Users/iwata/.go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/source.go:54 +0x88
created by golang.org/x/vuln/internal/vulncheck.source in goroutine 6
        /Users/iwata/.go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/source.go:52 +0x204
$ go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/iwata/Library/Caches/go-build'
GOENV='/Users/iwata/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/iwata/.go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/iwata/.go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/iwata/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/iwata/.go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/iwata/ghq/github.com/kouzoh-mercoin/mercoin-order-jp/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/2g/zplffj9d6z79_t1h6wbfkf240000gp/T/go-build3153323636=/tmp/go-build -gno-record-gcc-switches -fno-common'

@Zxilly
Copy link
Contributor

Zxilly commented Feb 9, 2024

Seems most error happens on darwin/arm64.

@zpavlinovic
Copy link
Contributor

Seems it happens on darwin exclusively AFAIKT. @H0llyW00dzZ's issue happens on windows with govulncheck v1.0.1, but not with v1.0.4

@jmdeal
Copy link

jmdeal commented Feb 13, 2024

We're experiencing the same issue, both on my local machine (darwin/arm64) and in an Ubuntu based GitHub runner. I've tried both v1.0.3 and v1.0.4 on my local machine. I'll have to check what's being used by the github runner but it should be at least v1.0.3.

@Zxilly
Copy link
Contributor

Zxilly commented Feb 13, 2024

@jmdeal Seems your job running with the 1.0.4

https://github.com/aws/karpenter-provider-aws/blob/1d566b9b0ad04d041e58e781c6485dcc67aeb58f/hack/toolchain.sh#L22C4-L22C56

It's happy to find a reproduced example on amd64.

@zpavlinovic
Copy link
Contributor

For folks that can reproduce the issue, can you paste here your go version -m govulncheck?

Similarly, can you reproduce the issue if you reinstall govulncheck with 1.22.0?

@jmdeal
Copy link

jmdeal commented Feb 15, 2024

Reinstallation appears to have fixed it on my machine, looks like v1.0.4 was installed with 1.21.7:

/Users/jmdeal/go/bin/govulncheck: go1.21.7
        path    golang.org/x/vuln/cmd/govulncheck
        mod     golang.org/x/vuln       v1.0.4  h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
        dep     golang.org/x/mod        v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
        dep     golang.org/x/sync       v0.6.0  h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
        dep     golang.org/x/tools      v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
        build   -buildmode=exe
        build   -compiler=gc
        build   DefaultGODEBUG=panicnil=1
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=arm64
        build   GOOS=darwin

No issues after reinstalling with 1.22.0.

/Users/jmdeal/go/bin/govulncheck: go1.22.0
        path    golang.org/x/vuln/cmd/govulncheck
        mod     golang.org/x/vuln       v1.0.4  h1:SP0mPeg2PmGCu03V+61EcQiOjmpri2XijexKdzv8Z1I=
        dep     golang.org/x/mod        v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=
        dep     golang.org/x/sync       v0.6.0  h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
        dep     golang.org/x/tools      v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc=
        build   -buildmode=exe
        build   -compiler=gc
        build   DefaultGODEBUG=httplaxcontentlength=1,httpmuxgo121=1,panicnil=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=arm64
        build   GOOS=darwin

I believed our CI job had reinstalled it when we bumped to 1.22, but after reviewing the logs again it looks like it pulled it from a cache. It's working now that we've cleared the cache and forced the reinstall.

I am wondering if this is expected / user error or should the version installed with v1.21.7 still worked? If it is expected we'll have to update our toolchain cache key to reference the go version going forward but that shouldn't be a problem.

@zpavlinovic
Copy link
Contributor

While we are investigating this more (the issue seems to be somewhere deep in the dependencies), we suggest folks reinstall govulncheck with go1.22 as a temporary workaround.

@H0llyW00dzZ
Copy link

also about this one when I tryna downgrade to v1.0.1 from v1.0.4

$ go install golang.org/x/vuln/cmd/govulncheck@v1.0.1
$ govulncheck -version
Go: go1.22.0
Scanner: govulncheck@v1.0.1
DB: https://vuln.go.dev
DB updated: 2024-02-20 17:50:57 +0000 UTC

No vulnerabilities found.

Share feedback at https://go.dev/s/govulncheck-feedback.
$ govulncheck ./...
Scanning your code and 387 packages across 30 dependent modules for known vulnerabilities...

No vulnerabilities found.

Share feedback at https://go.dev/s/govulncheck-feedback.

it working fine

@karanmun123
Copy link

Hi Team,

I am still having this issue with govulncheck. Are there any fixes, Please?

Retest With an Older Version of govulncheck (v1.0.1) - Status Failed
Retest With a Newer Version of govulncheck (v1.0.4) - Status Failed

Thanks!

@zpavlinovic
Copy link
Contributor

Hi Team,

I am still having this issue with govulncheck. Are there any fixes, Please?

Retest With an Older Version of govulncheck (v1.0.1) - Status Failed Retest With a Newer Version of govulncheck (v1.0.4) - Status Failed

Thanks!

Have you tried doing go install golang.org/x/vuln/cmd/govulncheck@latest with go1.22? Does that work for you?

Recompiling govulncheck itself with a new version of Go did the trick for a few other people. If that does not work, that is also a useful bit of information for us.

Broderick-Westrope added a commit to Broderick-Westrope/goenums that referenced this issue Mar 5, 2024
@roma-glushko
Copy link

Just upgrade my project from 1.21.5 to 1.22.1 and govulncheck has gotten broken in a similar way:

Scanning your code and 373 packages across 74 dependent modules for known vulnerabilities...

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x139581a]

goroutine 6153 [running]:
golang.org/x/tools/go/ssa.memberFromObject(0xc008dd4b00, {0x0, 0x0?}, {0x0, 0x0}, {0x0, 0x0})
        /Users/roman/go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:55 +0x5a
golang.org/x/tools/go/ssa.membersFromDecl(0xc008dd4b00, {0x156cb40?, 0xc008e8f6c0?}, {0x0, 0x0})
        /Users/roman/go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:178 +0x16b
golang.org/x/tools/go/ssa.(*Program).CreatePackage(0xc000127520, 0xc0087f8fc0, {0xc00862e4f8, 0x3, 0x3}, 0xc0089fc320, 0x1)
        /Users/roman/go/pkg/mod/golang.org/x/tools@v0.17.0/go/ssa/create.go:250 +0x865
golang.org/x/vuln/internal/vulncheck.buildSSA.func1(0xc000134240?)
        /Users/roman/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/utils.go:38 +0xe5
golang.org/x/vuln/internal/vulncheck.buildSSA({0xc01fce72c0, 0x39, 0xc00082af90?}, 0xc00021a340)
        /Users/roman/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/utils.go:46 +0x322
golang.org/x/vuln/internal/vulncheck.source.func1()
        /Users/roman/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/source.go:54 +0x8f
created by golang.org/x/vuln/internal/vulncheck.source in goroutine 6
        /Users/roman/go/pkg/mod/golang.org/x/vuln@v1.0.4/internal/vulncheck/source.go:52 +0x28e

govulncheck -version:

Go: go1.22.1
Scanner: govulncheck@v1.0.4
DB: https://vuln.go.dev
DB updated: 2024-03-07 18:30:25 +0000 UTC

No vulnerabilities found.

@picatz
Copy link

picatz commented Mar 21, 2024

👋 Also seeing this same bug, but without govulncheck in the mix. On both MacOS and Linux (GitHub runners).

The common denominator being the SSA package:

I am seeing a similar panic that points to these lines:

🤔 I wonder if memberFromObject is given nil (types.Object), and is calling obj.Name() on it, leading to the panic.

@zpavlinovic
Copy link
Contributor

The issue happens when govulncheck is built with go1.21 and earlier but is run against go1.22 and later.

There is a change in semantics for loops in go1.22. If govulncheck uses package loading logic from an earlier version, the loaded code would be incorrect for go1.22+. The actual crash point is in the dependencies and this is why it has been observed with other tools as well.

The fix for this is to avoid the crash and generate an appropriate error message. The error message instructs users to rebuild govulncheck with a newer Go version. The fix should be available as of this CL. We plan to tag the vuln repo soon.

Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vulncheck or vulndb Issues for the x/vuln or x/vulndb repo
Projects
None yet
Development

No branches or pull requests