[Git][ghc/ghc][master] rts/CheckUnload: Don't prepare to unload if we can't unload

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu Dec 12 09:43:32 UTC 2024


Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
34d3e8e6 by Ben Gamari at 2024-12-12T04:43:08-05:00
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.

- - - - -


1 changed file:

- rts/CheckUnload.c


Changes:

=====================================
rts/CheckUnload.c
=====================================
@@ -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);
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34d3e8e69b62b92cc438514f7fb8e37ce639efea

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/34d3e8e69b62b92cc438514f7fb8e37ce639efea
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20241212/fa012234/attachment-0001.html>


More information about the ghc-commits mailing list