Skip to content

cmd/compile: deferred log prints wrong line number #24839

Closed
@dc0d

Description

@dc0d

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.1 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

GOARCH="amd64"
GOBIN="/home/x2m2018/C/gobin"
GOCACHE="/home/x2m2018/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/x2m2018/C/gopath"
GORACE=""
GOROOT="/home/x2m2018/C/go"
GOTMPDIR=""
GOTOOLDIR="/home/x2m2018/C/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build020362735=/tmp/go-build -gno-record-gcc-switches"

What did you do?

*Logger.Println with log.Lshortfile flag, logs the wrong line number - Go code to reproduce this.

And the output is:

main.go 61 main.trace calling
main.go 61 main.trace calling
main.go 61 main.trace calling
main.go 58 main.call2 called
main.go 53 main.call1 called
main.go 47 main.testCustom called
NaClMain [ info  ] main.go:20: calling
NaClMain [ info  ] main.go:20: calling
NaClMain [ info  ] main.go:20: calling
NaClMain [ info  ] main.go:31: called
NaClMain [ info  ] main.go:27: called
NaClMain [ info  ] main.go:22: called

What did you expect to see?

The three lines of output which report line number 20 should be showing line number 61.

What did you see instead?

Line numbers logged by *Logger.Println are not correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions