Skip to content

runtime: go of nil func value crashes #8045

@dvyukov

Description

@dvyukov
go version devel +4a839bf01b58 Tue May 20 15:52:08 2014 +1000 linux/amd64

The program is:

package main
func main() {
    var f func()
    go f()
    select{}
}

Currently it crashes with:

        fatal error: unexpected signal during runtime execution
        [signal 0xb code=0x1 addr=0x0 pc=0x417e77]
        
        goroutine 16 [running]:
        runtime.throw(0x4561c5)
            src/pkg/runtime/panic.c:520 +0x69 fp=0x7ff05514de78
        runtime.sigpanic()
            src/pkg/runtime/os_linux.c:222 +0x3d fp=0x7ff05514de90
        runtime.gostartcallfn(0xc2080025c8, 0x0)
            src/pkg/runtime/stack.c:847 +0x27 fp=0x7ff05514deb0
        runtime.newproc1(0x0, 0x7ff05514df38, 0x0, 0x400c38)
            src/pkg/runtime/proc.c:1852 +0x137 fp=0x7ff05514def0
        runtime.newproc(0x0, 0x0)
            src/pkg/runtime/proc.c:1803 +0x53 fp=0x7ff05514df28
        main.main()
            /tmp/go-build923308582/main.go:9 +0x38 fp=0x7ff05514df50
        runtime.main()
            src/pkg/runtime/proc.c:247 +0x11a fp=0x7ff05514dfa8

This happens because runtime.gostartcallfn dereferences nil with m->locks>0.
This causes unrecoverable fatal error. The program must panic instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions