[commit: ghc] ghc-7.8: Fix linked list manipulation code (buggy on consecutive deletion) (f405460)
git at git.haskell.org
git at git.haskell.org
Mon Apr 14 13:53:14 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.8
Link : http://ghc.haskell.org/trac/ghc/changeset/f40546053913a2cffe158605337e35a319fe2804/ghc
>---------------------------------------------------------------
commit f40546053913a2cffe158605337e35a319fe2804
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Sat Apr 12 23:02:13 2014 -0700
Fix linked list manipulation code (buggy on consecutive deletion)
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
(cherry picked from commit e3938f3adac0093b23694fd347774244ce121478)
>---------------------------------------------------------------
f40546053913a2cffe158605337e35a319fe2804
rts/CheckUnload.c | 3 ++-
rts/Linker.c | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/rts/CheckUnload.c b/rts/CheckUnload.c
index 8692dea..b381fca 100644
--- a/rts/CheckUnload.c
+++ b/rts/CheckUnload.c
@@ -290,7 +290,7 @@ void checkUnload (StgClosure *static_objects)
// marked as unreferenced can be physically unloaded, because we
// have no references to it.
prev = NULL;
- for (oc = unloaded_objects; oc; prev = oc, oc = next) {
+ for (oc = unloaded_objects; oc; oc = next) {
next = oc->next;
if (oc->referenced == 0) {
if (prev == NULL) {
@@ -304,6 +304,7 @@ void checkUnload (StgClosure *static_objects)
} else {
IF_DEBUG(linker, debugBelch("Object file still in use: %"
PATH_FMT "\n", oc->fileName));
+ prev = oc;
}
}
diff --git a/rts/Linker.c b/rts/Linker.c
index 814f930..c577cce 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -2928,8 +2928,8 @@ unloadObj( pathchar *path )
IF_DEBUG(linker, debugBelch("unloadObj: %" PATH_FMT "\n", path));
prev = NULL;
- for (oc = objects; oc; prev = oc, oc = next) {
- next = oc->next;
+ for (oc = objects; oc; oc = next) {
+ next = oc->next; // oc might be freed
if (!pathcmp(oc->fileName,path)) {
@@ -2987,6 +2987,8 @@ unloadObj( pathchar *path )
/* This could be a member of an archive so continue
* unloading other members. */
unloadedAnyObj = HS_BOOL_TRUE;
+ } else {
+ prev = oc;
}
}
More information about the ghc-commits
mailing list