Skip to content

runtime: wrong line number in panic call stack #5856

Closed
@gopherbot

Description

@gopherbot

by daviddengcn:

1. What is a short input program that triggers the error?
package main

func PanicInGoSrc() {
    panic("panic")
}

var a string = "abc"

func doPanic() error {
    if a == "" {
        return nil  // Line 11
    }
    
    defer PanicInGoSrc()
    
    return nil          // Line 16
}

func main() {
    doPanic()
}

2. What is the full compiler output?
panic: panic

goroutine 1 [running]:
main.PanicInGoSrc()
        F:/job/go/src/wrongpanicline.go:4 +0x43
main.doPanic(0x0, 0x0)
        F:/job/go/src/wrongpanicline.go:11 +0x44
main.main()
        F:/job/go/src/wrongpanicline.go:20 +0x1e

goroutine 2 [runnable]:
exit status 2

3. What version of the compiler are you using?  (Run it with the -V flag.)
go version go1.1.1 windows/386

The line number in main.doPanic is not 11, should be 16, this confuse me a lot before I
found this is a compiler bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions