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

cmd/objdump: panic for source code annotation with too-large line directives #36683

Closed
dr2chase opened this issue Jan 21, 2020 · 1 comment
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dr2chase
Copy link
Contributor

What version of Go are you using (go version)?

Go almost-14

$ go version
go version devel +71239b4f49 Mon Jan 20 15:06:42 2020 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/drchase/Library/Caches/go-build"
GOENV="/Users/drchase/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/drchase/work/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/drchase/work/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/drchase/work/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gr/vvb66dqx6jl6lh8wckfd5p9w0095tn/T/go-build189264983=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I compiled this program, call it bogo.go, with go build bogo.go.
Then I run go tool objdump -S ./bogo > bogo.s

package main

func main() {
	println("Try 'go tool objdump -S ./bogo > bogo.s'")
	loop()
}

var x int64

func loop() {
//line bogo.go:9999999
	for x <= 1024*1024*1024 {
		x = x + 1
	}
}

What did you expect to see?

Not a panic

What did you see instead?

panic: runtime error: index out of range [9999998] with length 37

goroutine 1 [running]:
cmd/internal/objfile.(*FileCache).Line(0xc000141d70, 0xc00019f678, 0x7, 0x98967f, 0xc000141ab8, 0x0, 0x0, 0xc000141b18, 0x10dd412)
        /Users/drchase/work/go/src/cmd/internal/objfile/disasm.go:178 +0x602
cmd/internal/objfile.(*Disasm).Print.func1(0x10b5350, 0x2, 0xc00019f678, 0x7, 0x98967f, 0xc000090ce0, 0xd)
        /Users/drchase/work/go/src/cmd/internal/objfile/disasm.go:232 +0xd8
cmd/internal/objfile.(*Disasm).Decode(0xc00012e000, 0x10b5350, 0x10b536c, 0x0, 0x0, 0x0, 0xc000141e40)
        /Users/drchase/work/go/src/cmd/internal/objfile/disasm.go:283 +0x27b
cmd/internal/objfile.(*Disasm).Print(0xc00012e000, 0x11fa440, 0xc00000e018, 0x0, 0x1001000, 0xffffffffffffffff, 0x1)
        /Users/drchase/work/go/src/cmd/internal/objfile/disasm.go:227 +0x4e2
main.main()
        /Users/drchase/work/go/src/cmd/objdump/main.go:90 +0x615

This is related to #36570 (which is fixed).
Using similar methods I tried to crash both test coverage and pprof, but was unable to provoke a panic.

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 21, 2020
@toothrot toothrot added this to the Backlog milestone Jan 21, 2020
@gopherbot
Copy link

Change https://golang.org/cl/223081 mentions this issue: cmd/objdump: guard against out-of-range lines from directives.

@dmitshur dmitshur modified the milestones: Backlog, Go1.15 Jun 8, 2020
@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Jun 8, 2020
@golang golang locked and limited conversation to collaborators Jun 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants