Skip to content

panic: runtime error Crash in Orphaned gorutines cant be handled #47261

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

Closed
vkstack opened this issue Jul 17, 2021 · 1 comment
Closed

panic: runtime error Crash in Orphaned gorutines cant be handled #47261

vkstack opened this issue Jul 17, 2021 · 1 comment

Comments

@vkstack
Copy link

vkstack commented Jul 17, 2021

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

$ go version
go1.16.5

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/vajahatk/Library/Caches/go-build"
GOENV="/Users/vajahatk/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/vajahatk/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/vajahatk/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/vajahatk/work/dotpe/location/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dv/g91vgh2x58b0b8pcxv8qr_yh0000gn/T/go-build4233566118=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import (
	"fmt"
	"log"
	"net/http"
)

func main() {
	startServer()
}

func startServer() {
	mainchan := make(chan struct{})
	go func(ch chan<- struct{}) {
		defer func() {
			if r := recover(); r != nil {
				fmt.Println("recovered from crash\n", r)
				ch <- struct{}{}
			}
		}()
		http.HandleFunc("/divide", func(w http.ResponseWriter, req *http.Request) {
			go panic("this is to be catched")
			fmt.Fprintf(w, "Hello, \nyour question is submitted\t")
		})
		log.Fatal(http.ListenAndServe(":8081", nil))
	}(mainchan)
	<-mainchan
	fmt.Println("safe landing")
}

What did you expect to see?

safe landing

What did you see instead?

panic: this is to be catched

goroutine 7 [running]:
panic(0x1242be0, 0xc000012060)
        /usr/local/go/src/runtime/panic.go:1065 +0x565
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1371 +0x1
created by main.startServer.func1.2
        /Users/vajahatk/work/test/main.go:29 +0x1e5
exit status 2
@vkstack vkstack closed this as completed Jul 17, 2021
@vkstack vkstack reopened this Jul 17, 2021
@seankhliao
Copy link
Member

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@golang golang locked and limited conversation to collaborators Jul 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants