[Git][ghc/ghc][master] rts/CheckUnload: Reset old_objects if unload is skipped
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Dec 10 19:04:31 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
9efbc51f by Ben Gamari at 2024-12-10T14:03:48-05:00
rts/CheckUnload: Reset old_objects if unload is skipped
Previously `checkUnload` failed to reset `old_objects` when it decided
not to unload (e.g. due to heap profiling being enabled).
Fixes #24935.
- - - - -
1 changed file:
- rts/CheckUnload.c
Changes:
=====================================
rts/CheckUnload.c
=====================================
@@ -467,48 +467,44 @@ bool prepareUnloadCheck(void)
void checkUnload(void)
{
- if (global_s_indices == NULL) {
- return;
- } else if (!safeToUnload()) {
- return;
- }
-
// At this point we've marked all dynamically loaded static objects
// (including their dependencies) during GC, but not the root set of object
// code (loaded_objects). Mark the roots first, then unload any unmarked
// objects.
- OCSectionIndices *s_indices = global_s_indices;
- ASSERT(s_indices->sorted);
+ if (global_s_indices != NULL && safeToUnload()) {
+ OCSectionIndices *s_indices = global_s_indices;
+ ASSERT(s_indices->sorted);
- // Mark roots
- for (ObjectCode *oc = loaded_objects; oc != NULL; oc = oc->next_loaded_object) {
- markObjectLive(NULL, (W_)oc, NULL);
- }
+ // Mark roots
+ for (ObjectCode *oc = loaded_objects; oc != NULL; oc = oc->next_loaded_object) {
+ markObjectLive(NULL, (W_)oc, NULL);
+ }
- // Free unmarked objects
- ObjectCode *next = NULL;
- for (ObjectCode *oc = old_objects; oc != NULL; oc = next) {
- next = oc->next;
- ASSERT(oc->status == OBJECT_UNLOADED);
-
- // Symbols should be removed by unloadObj_.
- // NB (osa): If this assertion doesn't hold then freeObjectCode below
- // will corrupt symhash as keys of that table live in ObjectCodes. If
- // you see a segfault in a hash table operation in linker (in non-debug
- // RTS) then it's probably because this assertion did not hold.
- ASSERT(oc->symbols == NULL);
-
- if (oc->unloadable) {
- removeOCSectionIndices(s_indices, oc);
- freeObjectCode(oc);
- n_unloaded_objects -= 1;
- } else {
- // If we don't have enough information to
- // accurately determine the reachability of
- // the object then hold onto it.
- oc->next = objects;
- objects = oc;
+ // Free unmarked objects
+ ObjectCode *next = NULL;
+ for (ObjectCode *oc = old_objects; oc != NULL; oc = next) {
+ next = oc->next;
+ ASSERT(oc->status == OBJECT_UNLOADED);
+
+ // Symbols should be removed by unloadObj_.
+ // NB (osa): If this assertion doesn't hold then freeObjectCode below
+ // will corrupt symhash as keys of that table live in ObjectCodes. If
+ // you see a segfault in a hash table operation in linker (in non-debug
+ // RTS) then it's probably because this assertion did not hold.
+ ASSERT(oc->symbols == NULL);
+
+ if (oc->unloadable) {
+ removeOCSectionIndices(s_indices, oc);
+ freeObjectCode(oc);
+ n_unloaded_objects -= 1;
+ } else {
+ // If we don't have enough information to
+ // accurately determine the reachability of
+ // the object then hold onto it.
+ oc->next = objects;
+ objects = oc;
+ }
}
}
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9efbc51f99118e8f9c3abf2bcb6dc3295893ded6
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9efbc51f99118e8f9c3abf2bcb6dc3295893ded6
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/20241210/9d952866/attachment-0001.html>
More information about the ghc-commits
mailing list