Skip to content

cmd/compile: misleading panic on deferred func #29797

Open
@dsymonds

Description

@dsymonds

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

$ go version
go version devel +75f4aa86ba Thu Sep 27 22:02:08 2018 +0000 linux/amd64

What did you do?

https://play.golang.org/p/3aP7yqgWXdf

What did you expect to see?

The panic stack trace should point to where a nil pointer was dereferenced.

What did you see instead?

The panic stack trace pointed at an innocent line.

This is pretty similar to #14646 and #16011. The panic points at a line that is clearly quite capable of yielding that panic, so it led me on a wild goose chase. It took using gdb (gasp!) to figure out that the defer was involved. Consider this an argument for revisiting the "working as intended" judgment on #16011; it was a bug in my code, but the stack trace was very confusing.

If there was a way to indicate that the deferred function was being executed I would have spotted the issue earlier. The regular stack trace does not indicate that. gdb, however, shows runtime.jmpdefer as the immediate stack frame, which is how I figured it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions