Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Fix signals from exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
EnderIce2 committed Mar 28, 2024
1 parent 8be2e10 commit 5a00e91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
28 changes: 18 additions & 10 deletions core/panic/user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
dbgPrint(Frame);
#endif

int sigRet = -1;
switch (Frame->InterruptNumber)
{
case CPU::x86::PageFault:
Expand All @@ -169,15 +170,15 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
return true;
}

proc->Signals.SendSignal(SIGSEGV,
{Tasking::KILL_CRASH});
sigRet = proc->Signals.SendSignal(SIGSEGV,
{Tasking::KILL_CRASH});
break;
}
case CPU::x86::Debug:
case CPU::x86::Breakpoint:
{
proc->Signals.SendSignal(SIGTRAP,
{Tasking::KILL_CRASH});
sigRet = proc->Signals.SendSignal(SIGTRAP,
{Tasking::KILL_CRASH});
break;
}
case CPU::x86::DivideByZero:
Expand All @@ -186,21 +187,21 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
case CPU::x86::x87FloatingPoint:
case CPU::x86::SIMDFloatingPoint:
{
proc->Signals.SendSignal(SIGFPE,
{Tasking::KILL_CRASH});
sigRet = proc->Signals.SendSignal(SIGFPE,
{Tasking::KILL_CRASH});
break;
}
case CPU::x86::InvalidOpcode:
case CPU::x86::GeneralProtectionFault:
{
proc->Signals.SendSignal(SIGILL,
{Tasking::KILL_CRASH});
sigRet = proc->Signals.SendSignal(SIGILL,
{Tasking::KILL_CRASH});
break;
}
case CPU::x86::DeviceNotAvailable:
{
proc->Signals.SendSignal(SIGBUS,
{Tasking::KILL_CRASH});
sigRet = proc->Signals.SendSignal(SIGBUS,
{Tasking::KILL_CRASH});
break;
}
case CPU::x86::NonMaskableInterrupt:
Expand All @@ -221,6 +222,13 @@ nsa bool UserModeExceptionHandler(CPU::ExceptionFrame *Frame)
}
}

if (sigRet == 0)
{
trace("User mode exception handler handled");
thread->SetState(Tasking::Ready);
return true;
}

error("User mode exception handler failed");
return false;
}
4 changes: 2 additions & 2 deletions tasking/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ namespace Tasking
pcb->SetState(Zombie);
else
pcb->SetState(Terminated);
return 0;
return val.sival_int == Tasking::KILL_CRASH ? -EFAULT : 0;
}
case SIG_IGN:
{
Expand All @@ -635,7 +635,7 @@ namespace Tasking
pcb->SetState(CoreDump);
else
pcb->SetState(Terminated);
return 0;
return val.sival_int == Tasking::KILL_CRASH ? -EFAULT : 0;
}
case SIG_STOP:
{
Expand Down

0 comments on commit 5a00e91

Please sign in to comment.