Some cost centre stacks are not registered via registerCcsList()
In #15508 (closed) I observe that some closures have incorrect CCS field. To be able to catch this problem as early as possible I implemented a simple check:
static void
checkClosureProfSanity(const StgClosure *p)
{
StgProfHeader prof_hdr = p->header.prof;
CostCentreStack *ccs = prof_hdr.ccs;
// For now just make sure the CCS is a registered CCS and not a pointer to
// some random heap closure (happened before, see #15508).
for (CostCentreStack *ccs_ = CCS_LIST; ccs_; ccs_ = ccs_->prevStack) {
if (ccs == ccs_) {
return;
}
}
barf("CCS for closure %p is not registered: %p", (void*)p, (void*)ccs);
}
I call this on all closures before and after a GC. This assumes that all cost
centre stacks are registered via registerCcsList(), however this currently
does not hold. I was able to find two cases:
-
base_GHCziIOziHandleziFD_CAFs_cc_ccsis never registered (there are probably
a few CCSs per module like this which are never registered)
- None of the dynamically allocated CCSs are registered.
My question is: am I misunderstanding how the CCS registry (CCS_LIST) is
supposed to be used? I thought all CCSs should really be in that list, because
the list is used when reporting. Not registering a CCS means not reporting it.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.6.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Profiling |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |