summaryrefslogtreecommitdiff
path: root/rts/sm
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2019-01-10 12:42:04 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2019-01-10 12:42:04 +0300
commit82d1a88dec216d761b17252ede760da5c566007f (patch)
treef925f9294d73682ffccda2ea77374a8ceb685c8e /rts/sm
parent6486c6e49c53e75f37ed732b38c5be7ae64785e8 (diff)
downloadhaskell-82d1a88dec216d761b17252ede760da5c566007f.tar.gz
Implement a sanity check for CCS fields in profiling builds
This helped me debug one of the bugs in #15508. I'm not sure if this is a good idea, but it worked for me, so wanted to submit this as a MR.
Diffstat (limited to 'rts/sm')
-rw-r--r--rts/sm/Sanity.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c
index 1da3e4416f..28c9b432f8 100644
--- a/rts/sm/Sanity.c
+++ b/rts/sm/Sanity.c
@@ -29,6 +29,7 @@
#include "Arena.h"
#include "RetainerProfile.h"
#include "CNF.h"
+#include "Profiling.h" // prof_arena
/* -----------------------------------------------------------------------------
Forward decls.
@@ -210,6 +211,17 @@ checkPAP (StgClosure *tagged_fun, StgClosure** payload, StgWord n_args)
: GET_CLOSURE_TAG(tagged_fun) == fun_info->f.arity);
}
+#if defined(PROFILING)
+static void
+checkClosureProfSanity(const StgClosure *p)
+{
+ StgProfHeader prof_hdr = p->header.prof;
+ CostCentreStack *ccs = prof_hdr.ccs;
+ if (HEAP_ALLOCED_GC((void*)ccs)) {
+ checkPtrInArena((StgPtr)ccs, prof_arena);
+ }
+}
+#endif
StgOffset
checkClosure( const StgClosure* p )
@@ -225,6 +237,11 @@ checkClosure( const StgClosure* p )
if (IS_FORWARDING_PTR(info)) {
barf("checkClosure: found EVACUATED closure %d", info->type);
}
+
+#if defined(PROFILING)
+ checkClosureProfSanity(p);
+#endif
+
info = INFO_PTR_TO_STRUCT(info);
switch (info->type) {