diff --git a/Tests/Kernel/crash.cpp b/Tests/Kernel/crash.cpp index 513b10e243..d5be7cd87f 100644 --- a/Tests/Kernel/crash.cpp +++ b/Tests/Kernel/crash.cpp @@ -113,7 +113,7 @@ int main(int argc, char** argv) if (do_illegal_instruction || do_all_crash_types) { any_failures |= !Crash("Illegal instruction", []() { - asm volatile("ud2"); + __builtin_trap(); return Crash::Failure::DidNotCrash; }).run(run_type); } diff --git a/Tests/Kernel/null-deref-crash-during-pthread_join.cpp b/Tests/Kernel/null-deref-crash-during-pthread_join.cpp index 15872d92fd..f48c40e388 100644 --- a/Tests/Kernel/null-deref-crash-during-pthread_join.cpp +++ b/Tests/Kernel/null-deref-crash-during-pthread_join.cpp @@ -15,7 +15,7 @@ int main(int, char**) pthread_create( &tid, nullptr, [](void*) -> void* { sleep(1); - asm volatile("ud2"); + __builtin_trap(); return nullptr; }, nullptr); diff --git a/Userland/Libraries/LibC/stdlib.cpp b/Userland/Libraries/LibC/stdlib.cpp index 8a56fc9313..81759f4b1f 100644 --- a/Userland/Libraries/LibC/stdlib.cpp +++ b/Userland/Libraries/LibC/stdlib.cpp @@ -214,8 +214,9 @@ int atexit(void (*handler)()) void _abort() { - asm volatile("ud2"); - __builtin_unreachable(); + // According to the GCC manual __builtin_trap() can call abort() so using it here might not seem safe at first. However, + // on all the platforms we support GCC emits an undefined instruction instead of a call. + __builtin_trap(); } void abort()