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: bad position information for inlined functions #21184

Closed
mdempsky opened this issue Jul 27, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@mdempsky
Copy link
Member

commented Jul 27, 2017

In the objdump output below, we see "q.go:3", which is nonsensical because this is the import statement's line number.

This happens because these instructions are getting their position information from the p.t struct literal's field initializers, but we're currently failing to serialize position information for OSTRUCTKEY. As a result, the nod(OSTRUCTKEY, ...) calls in bimport.go instead inherit the import statement's position information from lineno.

There are a handful of other nod calls (e.g., the OCONV nodes for importing OLITERALs, and the OIND and OADDR for importing OPTRLITs). These should all use explicit position information instead.

Related #19683.

/cc @hyangah @heschik @dr2chase

$ go tool compile p.go
$ go tool compile q.go
$ go tool link q.o
$ go tool objdump -s main.main a.out
TEXT main.main(SB) /tmp/q.go
  q.go:5            0x450970                64488b0c25f8ffffff      MOVQ FS:0xfffffff8, CX
  q.go:5            0x450979                488d842478ffffff        LEAQ 0xffffff78(SP), AX
  q.go:5            0x450981                483b4110                CMPQ 0x10(CX), AX
  q.go:5            0x450985                7641                    JBE 0x4509c8
  q.go:5            0x450987                4881ec08010000          SUBQ $0x108, SP
  q.go:5            0x45098e                4889ac2400010000        MOVQ BP, 0x100(SP)
  q.go:5            0x450996                488dac2400010000        LEAQ 0x100(SP), BP
  q.go:3            0x45099e                488d3c24                LEAQ 0(SP), DI
  q.go:3            0x4509a2                0f57c0                  XORPS X0, X0
  q.go:3            0x4509a5                48896c24f0              MOVQ BP, -0x10(SP)
  q.go:3            0x4509aa                488d6c24f0              LEAQ -0x10(SP), BP
  q.go:3            0x4509af                e8b0a3ffff              CALL 0x44ad64
  q.go:3            0x4509b4                488b6d00                MOVQ 0(BP), BP
  q.go:7            0x4509b8                488bac2400010000        MOVQ 0x100(SP), BP
  q.go:7            0x4509c0                4881c408010000          ADDQ $0x108, SP
  q.go:7            0x4509c7                c3                      RET
  q.go:5            0x4509c8                e8837dffff              CALL runtime.morestack_noctxt(SB)
  q.go:5            0x4509cd                eba1                    JMP main.main(SB)

$ cat p.go
package p

type t struct {
    b [256]byte
}

func F() interface{} {
    return &t{
            b: [256]byte{},
    }
}

$ cat q.go
package main

import "./p"

func main() {
    p.F()
}

@mdempsky mdempsky added this to the Go1.10 milestone Jul 27, 2017

@mdempsky mdempsky self-assigned this Jul 27, 2017

@mdempsky

This comment has been minimized.

Copy link
Member Author

commented Nov 29, 2017

@dr2chase fixed this with CL 80115.

@mdempsky mdempsky closed this Nov 29, 2017

@golang golang locked and limited conversation to collaborators Nov 29, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.