Hi,

It took a while to understand what's going on.
 

> I'm not sure which part of the os/signal docs you are thinking of. 


I'm referring to "Go programs that use cgo or SWIG", last paragraph ("If 
the Go signal handler is invoked on a non-Go thread not running Go code 
[...]"). I couldn't get any information about the crash in C from the Go 
signal handler. It remained silent and just quitted the program.

Crashes in Go code will work regardless of whether they are running on 

threads started by C or not.  So I assume you are talking about 
> crashes in C.  How do you want to handle those crashes?  Do you just 
> want to try to dump the stack?  How do you want to handle other C 
> threads when one C thread crashes? 
>

Yes, I meant crashes in C. I want to create a crash dump file and dump all 
C threads and Go routines. 

I do agree that your code should work in principle, and I'm not sure 
> why it doesn't. 
>
> If all you wan to do is handle SIGSEGV when it occurs in a C thread, 
> it may work to call signal.Notify(c, syscall.SIGSEGV).  The channel 
> will receive a signal wen a SIGSEGV occurs in C code.  At that point 
> it's not safe to continue, but it is safe to take whatever action you 
> like to dump C threads.  I'm not sure this will work, because it 
> depends on what happens when the SIGSEGV signal handler returns to the 
> C code that triggered the SIGSEGV. 
>

The reason for the morestack call is, that sigtramp is not called in my 
code example. The sa_tramp seems to be overwritten in my call to 
sigaction(int,struct sigaction*,struct sigaction*) and I cannot retrieve 
the original trampoline function via __sigaction(int, struct __sigaction*, 
struct sigaction*), to call it in my handler. Calling it directly would 
probably not work anyway, as sigtrampgo already calls sigreturn, but I want 
to be able to do calculations in the C handler if the Go handler has 
returned. So, I'm quite stuck here. Do you have any ideas?

I will open another thread to discuss the "correct way" to create a crash 
dump file for Go and C, and discuss my experiments. I'll leave this thread 
for the signal handler replacement on Darwin.

Thanks!
Martin

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to