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

rts/CheckUnload: Don't prepare to unload if we can't unload

Previously `prepareUnloadCheck` would move the `objects` list to
`old_objects` even when profiling (where we cannot unload). This caused
us to vacate the `objects` list during major GCs, losing track of loaded
objects. Fix this by ensuring that `prepareUnloadCheck` and
`checkUnload` both use the same short-cutting logic.
parent ef2052a8
No related branches found
No related tags found
No related merge requests found
Pipeline #104382 passed with warnings
......@@ -166,7 +166,7 @@ ObjectCode *loaded_objects;
static OCSectionIndices *global_s_indices = NULL;
// Is it safe for us to unload code?
static bool safeToUnload(void)
static bool tryToUnload(void)
{
if (RtsFlags.ProfFlags.doHeapProfile != NO_HEAP_PROFILING) {
// We mustn't unload anything as the heap census may contain
......@@ -174,7 +174,8 @@ static bool safeToUnload(void)
// See #24512.
return false;
}
return true;
return global_s_indices != NULL;
}
static OCSectionIndices *createOCSectionIndices(void)
......@@ -432,7 +433,7 @@ static bool markObjectLive(void *data STG_UNUSED, StgWord key, const void *value
void markObjectCode(const void *addr)
{
if (global_s_indices == NULL) {
if (!tryToUnload()) {
return;
}
......@@ -450,7 +451,7 @@ void markObjectCode(const void *addr)
// unloading.
bool prepareUnloadCheck(void)
{
if (global_s_indices == NULL) {
if (!tryToUnload()) {
return false;
}
......@@ -472,7 +473,7 @@ void checkUnload(void)
// code (loaded_objects). Mark the roots first, then unload any unmarked
// objects.
if (global_s_indices != NULL && safeToUnload()) {
if (tryToUnload()) {
OCSectionIndices *s_indices = global_s_indices;
ASSERT(s_indices->sorted);
......
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