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/compile: wrong line number in error message #50133

Open
zigo101 opened this issue Dec 13, 2021 · 1 comment
Open

cmd/compile: wrong line number in error message #50133

zigo101 opened this issue Dec 13, 2021 · 1 comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zigo101
Copy link

zigo101 commented Dec 13, 2021

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

$ go version
go version go1.17.5 linux/amd64
go version devel go1.18-9bfe09d78b Mon Dec 13 06:35:06 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

const N = 2000000000

var x [N+1]byte

var y *[N+1]byte

func main() {
	var a [N+1]byte // okay
	y = &a // main.go:11:4: main.x: symbol too large (2000000001 bytes > 2000000000 bytes)
}

What did you expect to see?

main.go:5:5: main.x: symbol too large (2000000001 bytes > 2000000000 bytes)

What did you see instead?

main.go:11:4: main.x: symbol too large (2000000001 bytes > 2000000000 bytes)
@cherrymui cherrymui added this to the Backlog milestone Dec 13, 2021
@cherrymui cherrymui added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 13, 2021
@cherrymui
Copy link
Member

cherrymui commented Dec 13, 2021

This error is from the object file writer, https://cs.opensource.google/go/go/+/master:src/cmd/internal/obj/objfile.go;l=371 , which is called from https://cs.opensource.google/go/go/+/master:src/cmd/compile/internal/gc/obj.go;l=182
The object file writer does not have information about the line number, and LSym doesn't carry a line number either. The line number in the message is from base.Pos, whatever that is last updated (ctxt.Diag calls base.Errorf).

Maybe we could set base.Pos to NoXPos when writing object files, so it will not print a misleading line number. Or we could perhaps move the "symbol too large" detection earlier into the compiler (but there may be other errors emitted by the object file writer which may have the same problem).

cc @griesemer @mdempsky

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@mknyszek mknyszek moved this to Triage Backlog in Go Compiler / Runtime Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Triage Backlog
Development

No branches or pull requests

3 participants