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: no debug information emitted for type used only as initializer #46670

Open
heschi opened this issue Jun 9, 2021 · 0 comments
Open
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

@heschi
Copy link
Contributor

heschi commented Jun 9, 2021

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

$ go version
1.16.3

Does this issue reproduce with the latest release?

Yes, and at tip.

What did you do?

Debug the following program:

package main

import "fmt"

type inner struct{ val string }

type outer struct {
        val interface{}
}

var g = outer {
        val: inner{val: "val"},
}

func main() {
        fmt.Println(g) // breakpoint here and inspect g
}

What did you expect to see?

A legible value for g.

What did you see instead?

An error: val: (unreadable interface type "main.inner" not found for 0x555a68: no type entry found, use 'types' for a list of valid types),}

I think the problem is that because the inner type is only used in an initializer, there's never a need to reference its runtime type symbol in code. Because of that, the linker is able to prune the type symbol, and therefore never generates DWARF for the type.

cc @thanm

@heschi heschi added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 9, 2021
@heschi heschi added this to the Unplanned milestone Jun 9, 2021
@thanm thanm self-assigned this Jun 9, 2021
@rsc rsc unassigned thanm Jun 23, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 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
None yet
Development

No branches or pull requests

3 participants