On Thu, Sep 17, 2020 at 12:09 PM Tamás Gulácsi <tgulacs...@gmail.com> wrote: > > Can you provide some skim of a C-side signal handler that could induce a Go > panic? > All I want is to have an error on Go side, instead of a crash (though it may > be safer to have a crash...).
I can't think of any safe way that a C signal handler could cause a panic in the goroutine that called the C code that made the invalid memory reference. You could in principle have a C signal handler call a Go function that sends a message on a buffered channel that tells some other goroutine to panic. I think that could be safe. But it would not be safe for a C signal handler to call a Go function that calls panic. That would leave the program with most signals blocked. Ian > Ian Lance Taylor a következőt írta (2020. szeptember 17., csütörtök, 21:00:52 > UTC+2): >> >> On Thu, Sep 17, 2020 at 8:52 AM Tamás Gulácsi <tgula...@gmail.com> wrote: >> > >> > I'm searching for help in https://github.com/godror/godror/issues/100 - >> > I've added a recover, called debug.SetPanicOnFault, without success: the >> > extra free still panics with SIGSEGV, and the recover does not catch it >> > (or I coded it wrongly): >> > https://github.com/godror/godror/blob/2dab250ab19e158ba97699841f40c9de9d061f29/stmt.go#L306 >> > >> > panic: https://github.com/godror/godror/issues/100#issuecomment-694192603 >> >> When a SIGSEGV occurs while running C code called via cgo, that >> SIGSEGV is not turned into a Go panic. >> >> It works this way both because 1) C is not a memory-safe language, and >> if the C code has not installed a signal handler there is no reason to >> think that the C code is prepared to carry on after a segmentation >> violation; 2) the mechanism that Go uses to turn a memory error into a >> panic can only work for Go code, not for C code. >> >> Ian > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/30ca05ec-255b-4d67-b45f-89fde5396bb6n%40googlegroups.com. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcU-fYa2Eg7WCxM97OjZW_rPkTF1H_C4wyieXKguY%2Bkcaw%40mail.gmail.com.