mirror of
https://github.com/RGBCube/serenity
synced 2025-08-23 05:17:35 +00:00
Kernel+LibC: Clean up how assertions work in the kernel and LibC
This also brings LibC's abort() function closer to the spec.
This commit is contained in:
parent
33a9b2a3c3
commit
f033416893
13 changed files with 36 additions and 73 deletions
|
@ -163,7 +163,6 @@ private:
|
|||
int virt$connect(int sockfd, FlatPtr address, socklen_t address_size);
|
||||
int virt$shutdown(int sockfd, int how);
|
||||
void virt$sync();
|
||||
void virt$abort();
|
||||
void virt$exit(int);
|
||||
ssize_t virt$getrandom(FlatPtr buffer, size_t buffer_size, unsigned int flags);
|
||||
int virt$chdir(FlatPtr, size_t);
|
||||
|
|
|
@ -220,9 +220,6 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
|
|||
case SC_sync:
|
||||
virt$sync();
|
||||
return 0;
|
||||
case SC_abort:
|
||||
virt$abort();
|
||||
return 0;
|
||||
case SC_exit:
|
||||
virt$exit((int)arg1);
|
||||
return 0;
|
||||
|
@ -1036,14 +1033,6 @@ void Emulator::virt$sync()
|
|||
syscall(SC_sync);
|
||||
}
|
||||
|
||||
void Emulator::virt$abort()
|
||||
{
|
||||
reportln("\n=={}== \033[33;1mSyscall: abort\033[0m, shutting down!", getpid());
|
||||
m_exit_status = 127;
|
||||
m_shutdown = true;
|
||||
dump_backtrace();
|
||||
}
|
||||
|
||||
void Emulator::virt$exit(int status)
|
||||
{
|
||||
reportln("\n=={}== \033[33;1mSyscall: exit({})\033[0m, shutting down!", getpid(), status);
|
||||
|
|
|
@ -48,13 +48,12 @@ void __assertion_failed(const char* msg)
|
|||
{ msg, strlen(msg) },
|
||||
};
|
||||
syscall(SC_set_coredump_metadata, ¶ms);
|
||||
syscall(SC_abort);
|
||||
for (;;) { }
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void __crash()
|
||||
void _abort()
|
||||
{
|
||||
asm volatile("ud2");
|
||||
__builtin_unreachable();
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
__BEGIN_DECLS
|
||||
|
||||
#ifdef DEBUG
|
||||
__attribute__((noreturn)) void __assertion_failed(const char* msg);
|
||||
[[noreturn]] void __assertion_failed(const char* msg);
|
||||
# define __stringify_helper(x) # x
|
||||
# define __stringify(x) __stringify_helper(x)
|
||||
# define assert(expr) \
|
||||
|
@ -42,12 +42,11 @@ __attribute__((noreturn)) void __assertion_failed(const char* msg);
|
|||
# define VERIFY_NOT_REACHED() assert(false)
|
||||
#else
|
||||
# define assert(expr) ((void)(0))
|
||||
# define VERIFY_NOT_REACHED() CRASH()
|
||||
# define VERIFY_NOT_REACHED() _abort()
|
||||
#endif
|
||||
|
||||
__attribute__((noreturn)) void __crash();
|
||||
[[noreturn]] void _abort();
|
||||
|
||||
#define CRASH() __crash()
|
||||
#define VERIFY assert
|
||||
#define TODO VERIFY_NOT_REACHED
|
||||
|
||||
|
|
|
@ -249,8 +249,12 @@ void abort()
|
|||
// For starters, send ourselves a SIGABRT.
|
||||
raise(SIGABRT);
|
||||
// If that didn't kill us, try harder.
|
||||
raise(SIGKILL);
|
||||
_exit(127);
|
||||
sigset_t set;
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGABRT);
|
||||
sigprocmask(SIG_UNBLOCK, &set, nullptr);
|
||||
raise(SIGABRT);
|
||||
_abort();
|
||||
}
|
||||
|
||||
static HashTable<const char*> s_malloced_environment_variables;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
static bool is_deadly_syscall(int fn)
|
||||
{
|
||||
return fn == SC_exit || fn == SC_fork || fn == SC_sigreturn || fn == SC_exit_thread || fn == SC_abort;
|
||||
return fn == SC_exit || fn == SC_fork || fn == SC_sigreturn || fn == SC_exit_thread;
|
||||
}
|
||||
|
||||
static bool is_unfuzzable_syscall(int fn)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue