Skip to content
Snippets Groups Projects
Commit 8b2513e8 authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

rts/linker: Don't unload code when profiling is enabled

The heap census may contain references (e.g. `Counter.identity`) to
static data which must be available when the census is reported at the
end of execution.

Fixes #24512.
parent dc207d06
No related branches found
No related tags found
No related merge requests found
......@@ -165,6 +165,18 @@ ObjectCode *loaded_objects;
// map static closures to their ObjectCode.
static OCSectionIndices *global_s_indices = NULL;
// Is it safe for us to unload code?
static bool safeToUnload(void)
{
if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) {
// We mustn't unload anything as the heap census may contain
// references into static data (e.g. cost centre names).
// See #24512.
return false;
}
return true;
}
static OCSectionIndices *createOCSectionIndices(void)
{
// TODO (osa): Maybe initialize as empty (without allocation) and allocate
......@@ -457,6 +469,8 @@ void checkUnload(void)
{
if (global_s_indices == NULL) {
return;
} else if (!safeToUnload()) {
return;
}
// At this point we've marked all dynamically loaded static objects
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment