Fixed Linux specific bug causing lack of stack overflow traces.

This commit is contained in:
Gavin Whelan 2014-03-04 14:48:59 -08:00
parent f8cb035962
commit c85fd1fe35
2 changed files with 20 additions and 4 deletions

View File

@ -42,6 +42,14 @@ typedef enum {
volatile u2_kill Sigcause; // reasons for exception volatile u2_kill Sigcause; // reasons for exception
static void _lo_cont(void *arg1, void *arg2, void *arg3)
{
(void)(arg1);
(void)(arg2);
(void)(arg3);
siglongjmp(Signal_buf, 1);
}
static void static void
_lo_signal_handle_over(int emergency, stackoverflow_context_t scp) _lo_signal_handle_over(int emergency, stackoverflow_context_t scp)
{ {
@ -60,7 +68,7 @@ _lo_signal_handle_over(int emergency, stackoverflow_context_t scp)
#endif #endif
{ {
Sigcause = sig_overflow; Sigcause = sig_overflow;
longjmp(Signal_buf, 1); sigsegv_leave_handler(_lo_cont, NULL, NULL, NULL);
} }
} }
@ -329,7 +337,7 @@ u2_lo_soft(u2_reck* rec_u, c3_w sec_w, u2_funk fun_f, u2_noun arg)
u2_unix_ef_hold(); u2_unix_ef_hold();
_lo_signal_deep(sec_w); _lo_signal_deep(sec_w);
if ( 0 != setjmp(Signal_buf) ) { if ( 0 != sigsetjmp(Signal_buf, 1) ) {
u2_noun tax, pre, mok; u2_noun tax, pre, mok;
// return to blank state // return to blank state

View File

@ -246,6 +246,14 @@ static uint8_t Sigstk[SIGSTKSZ];
volatile enum { sig_none, sig_overflow, sig_interrupt } Sigcause; volatile enum { sig_none, sig_overflow, sig_interrupt } Sigcause;
static void _main_cont(void *arg1, void *arg2, void *arg3)
{
(void)(arg1);
(void)(arg2);
(void)(arg3);
siglongjmp(Signal_buf, 1);
}
static void static void
overflow_handler(int emergency, stackoverflow_context_t scp) overflow_handler(int emergency, stackoverflow_context_t scp)
{ {
@ -254,7 +262,7 @@ overflow_handler(int emergency, stackoverflow_context_t scp)
exit(1); exit(1);
} else { } else {
Sigcause = sig_overflow; Sigcause = sig_overflow;
longjmp(Signal_buf, 1); sigsegv_leave_handler(_main_cont, NULL, NULL, NULL);
} }
} }
@ -367,7 +375,7 @@ main(c3_i argc,
// we get a signal, we force the system back into the just-booted state. // we get a signal, we force the system back into the just-booted state.
// If anything goes wrong during boot (above), it's curtains. // If anything goes wrong during boot (above), it's curtains.
{ {
if ( 0 != setjmp(Signal_buf) ) { if ( 0 != sigsetjmp(Signal_buf, 1) ) {
switch ( Sigcause ) { switch ( Sigcause ) {
case sig_overflow: printf("[stack overflow]\r\n"); break; case sig_overflow: printf("[stack overflow]\r\n"); break;
case sig_interrupt: printf("[interrupt]\r\n"); break; case sig_interrupt: printf("[interrupt]\r\n"); break;