diff --git a/repos/base/src/base/thread/thread.cc b/repos/base/src/base/thread/thread.cc
index 26270ec52b..da1dfc9e3e 100644
--- a/repos/base/src/base/thread/thread.cc
+++ b/repos/base/src/base/thread/thread.cc
@@ -13,6 +13,7 @@
#include
#include
+#include
#include
#include
#include
@@ -198,6 +199,12 @@ Thread_base::Thread_base(size_t weight, const char *name, size_t stack_size,
Thread_base::~Thread_base()
{
+ if (Thread_base::myself() == this) {
+ PERR("thread '%s' tried to self de-struct - sleeping forever.",
+ _context->name);
+ sleep_forever();
+ }
+
_deinit_platform_thread();
_free_context(_context);