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: mangled DWARF location for incoming string parameter #47354

Open
thanm opened this issue Jul 22, 2021 · 0 comments
Open

cmd/compile: mangled DWARF location for incoming string parameter #47354

thanm opened this issue Jul 22, 2021 · 0 comments
Assignees
Milestone

Comments

@thanm
Copy link
Contributor

@thanm thanm commented Jul 22, 2021

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

This is with Go 1.17/tip.

Does this issue reproduce with the latest release?

Yes.

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

linux/amd64

What did you do?

Build this program:

package main

var G int

//go:noinline
func docall(f func()) {
	f()
}

//go:noinline
func another(x int) {
	println(G)
}

//go:noinline
func livestring(s string) {
	docall(func() {
		println("s is", s)
	})
	G++
	another(0)
}

//go:noinline
func livestring2(s string) {
	docall(func() {
		println("s is", s)
	})
	G++
	another(int(s[0]))
}

func main() {
	livestring("foo")
	livestring2("bar")
}

If you stop in 'livestring2", the DWARF location expression emitted for the parameter 's' is damaged/incorrect.

$ gdb livestring
...
(gdb) b main.livestring2
Breakpoint 1 at 0x455680: file /usr/local/google/home/thanm/livestring.go, line 25.
(gdb) run
Starting program: /usr/local/google/home/thanm/livestring 
...
Thread 1 "livestring" hit Breakpoint 1, main.livestring2 (s=<error reading variable: access outside bounds of object referenced via synthetic pointer>) at /usr/local/google/home/thanm/livestring.go:25
25	func livestring2(s string) {
(gdb) p s
access outside bounds of object referenced via synthetic pointer
(gdb) info address s
Symbol "s" is multi-location:
  Base address 0x455680  Range 0x455680-0x4556c8: a variable in $rax [8-byte piece], and a variable in $rax [8-byte piece], and a complex DWARF expression:
     0: DW_OP_fbreg 8
    [8-byte piece], and a complex DWARF expression:
     0: DW_OP_fbreg 8
    [8-byte piece]
  Range 0x4556c8-0x45571b: a complex DWARF expression:
     0: DW_OP_call_frame_cfa
    [8-byte piece], and a complex DWARF expression:
     0: DW_OP_call_frame_cfa
    [8-byte piece], and a complex DWARF expression:
     0: DW_OP_fbreg 8
    [8-byte piece], and a complex DWARF expression:
     0: DW_OP_fbreg 8
    [8-byte piece]
.
(gdb) 

What did you expect to see?

Sane location expression

What did you see instead?

Malformed location expression. We should not be seeing 4 pieces, this is only a 2-piece variable. Something is going wrong somewhere along the line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants