On Mon, Aug 30, 2021 at 6:52 PM 'Vina C.' via golang-nuts
<golang-nuts@googlegroups.com> wrote:
>
> We have a java web application calling C program which in turn using go 
> program as a library. The go library was build with --buildmode= c-shared. 
> Now we got a crash with the application, but there is no call stack for go 
> program. We are thinking that it might be that java signal handler handles 
> SIGSEGV differently from golang's. So we would like to see if we could reset 
> signal handler in golang's to default. I have read package signal, and looks 
> to me that Reset function only "undoes the effect of any prior calls to 
> Notify".  And how to set the signal handler to default without calling Notify 
> before?

When the shared library is initialized, the Go runtime will install a
signal handler for SIGSEGV.  There is no way to tell the library to
reinstall the signal handler.  Go programs won't work correctly in all
cases if the Go signal handler is not installed (although they will
mostly work, they just won't correctly handles things like nil pointer
dereferences).

With -buildmode=c-shared, if a SIGSEGV handler was already installed
at the time that the shared library was initialized, and if the Go
SIGSEGV handler sees a signal that occurred in non-Go code, the Go
signal handler will pass the signal on to the previously installed
signal handler.

Hope this helps.  Cross-language signal handling can get complicated.

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/CAOyqgcVfn7BO0fn-QqrtMced4K8YnRmjRBX9YiXzXfSt0NNt3g%40mail.gmail.com.

Reply via email to