From dea8a144f5d9e4a4fb6c8d503adc1d7f4dc79aa6 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Tue, 28 May 2024 18:52:16 +0000
Subject: [PATCH] rts: fix checkClosure error message

This patch fixes an error message in checkClosure() when the closure
has already been evacuated. The previous logic was meant to print the
evacuated closure's type in the error message, but it was completely
wrong, given info was not really an info table, but a tagged pointer
that points to the closure's new address.
---
 rts/sm/Sanity.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c
index 1de1a7f0d95..bf4d1e8d0e5 100644
--- a/rts/sm/Sanity.c
+++ b/rts/sm/Sanity.c
@@ -359,7 +359,8 @@ checkClosure( const StgClosure* p )
     load_load_barrier();
 
     if (IS_FORWARDING_PTR(info)) {
-        barf("checkClosure: found EVACUATED closure %d", info->type);
+        ASSERT(LOOKS_LIKE_CLOSURE_PTR(info));
+        barf("checkClosure: found EVACUATED closure %u", GET_INFO((StgClosure*)UN_FORWARDING_PTR(info))->type);
     }
 
 #if defined(PROFILING)
-- 
GitLab