mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-04-01 13:29:32 +00:00
Make sure to initialize alt stacks before SIGSEGV handlers
This commit is contained in:
parent
3e5c98c7d4
commit
380d4f294e
@ -510,6 +510,27 @@ int main(int argc, char **argv)
|
||||
mon_init();
|
||||
#endif
|
||||
|
||||
#if !EMULATED_PPC
|
||||
// Create and install stacks for signal handlers
|
||||
for (int i = 0; i < SIG_STACK_COUNT; i++) {
|
||||
void *sig_stack = malloc(SIG_STACK_SIZE);
|
||||
D(bug("Signal stack %d at %p\n", i, sig_stack));
|
||||
if (sig_stack == NULL) {
|
||||
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR));
|
||||
goto quit;
|
||||
}
|
||||
sig_stacks[i].ss_sp = sig_stack;
|
||||
sig_stacks[i].ss_flags = 0;
|
||||
sig_stacks[i].ss_size = SIG_STACK_SIZE;
|
||||
}
|
||||
sig_stack_id = 0;
|
||||
if (sigaltstack(&sig_stacks[0], NULL) < 0) {
|
||||
sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno));
|
||||
ErrorAlert(str);
|
||||
goto quit;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !EMULATED_PPC
|
||||
// Install SIGSEGV and SIGBUS handlers
|
||||
sigemptyset(&sigsegv_action.sa_mask); // Block interrupts during SEGV handling
|
||||
@ -972,27 +993,6 @@ int main(int argc, char **argv)
|
||||
nvram_thread_active = (pthread_create(&nvram_thread, NULL, nvram_func, NULL) == 0);
|
||||
D(bug("NVRAM thread installed (%ld)\n", nvram_thread));
|
||||
|
||||
#if !EMULATED_PPC
|
||||
// Create and install stacks for signal handlers
|
||||
for (int i = 0; i < SIG_STACK_COUNT; i++) {
|
||||
void *sig_stack = malloc(SIG_STACK_SIZE);
|
||||
D(bug("Signal stack %d at %p\n", i, sig_stack));
|
||||
if (sig_stack == NULL) {
|
||||
ErrorAlert(GetString(STR_NOT_ENOUGH_MEMORY_ERR));
|
||||
goto quit;
|
||||
}
|
||||
sig_stacks[i].ss_sp = sig_stack;
|
||||
sig_stacks[i].ss_flags = 0;
|
||||
sig_stacks[i].ss_size = SIG_STACK_SIZE;
|
||||
}
|
||||
sig_stack_id = 0;
|
||||
if (sigaltstack(&sig_stacks[0], NULL) < 0) {
|
||||
sprintf(str, GetString(STR_SIGALTSTACK_ERR), strerror(errno));
|
||||
ErrorAlert(str);
|
||||
goto quit;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !EMULATED_PPC
|
||||
// Install SIGILL handler
|
||||
sigemptyset(&sigill_action.sa_mask); // Block interrupts during ILL handling
|
||||
|
Loading…
x
Reference in New Issue
Block a user