Index: kernel/generic/src/sysinfo/stats.c
===================================================================
--- kernel/generic/src/sysinfo/stats.c	(revision fe7bcf13e7bb4dccf0289632006b2e240a751683)
+++ kernel/generic/src/sysinfo/stats.c	(revision c7326f21034f5be327fe7a10a07986dddd6cac9b)
@@ -332,5 +332,5 @@
     bool dry_run, void *data)
 {
-	/* Messing with threads structures, avoid deadlock */
+	/* Messing with threads structures */
 	irq_spinlock_lock(&threads_lock, true);
 
@@ -597,5 +597,5 @@
 		return ret;
 
-	/* Messing with threads structures, avoid deadlock */
+	/* Messing with threads structures */
 	irq_spinlock_lock(&threads_lock, true);
 
@@ -627,10 +627,13 @@
 		ret.data.size = sizeof(stats_thread_t);
 
-		/* Hand-over-hand locking */
-		irq_spinlock_exchange(&threads_lock, &thread->lock);
-
+		/*
+		 * Replaced hand-over-hand locking with regular nested sections
+		 * to avoid weak reference leak issues.
+		 */
+		irq_spinlock_lock(&thread->lock, false);
 		produce_stats_thread(thread, stats_thread);
-
-		irq_spinlock_unlock(&thread->lock, true);
+		irq_spinlock_unlock(&thread->lock, false);
+
+		irq_spinlock_unlock(&threads_lock, true);
 	}
 
@@ -847,6 +850,4 @@
 void kload(void *arg)
 {
-	thread_detach(THREAD);
-
 	while (true) {
 		size_t ready = atomic_load(&nrdy);
