summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorPhuong Trinh <lolotp@fb.com>2019-04-25 18:44:02 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-13 02:48:50 -0400
commitfc6b23be509e290f8d27775a1c637284a335ed81 (patch)
treee977d63250a03296011b58434034cb2c471bf43f /rts/Linker.c
parent5ffc266e9c5ec8ed6010835165a65bd1f6b56dd4 (diff)
downloadhaskell-fc6b23be509e290f8d27775a1c637284a335ed81.tar.gz
Fix #16525: ObjectCode freed wrongly because of lack of info header check
`checkUnload` currently doesn't check the info header of static objects. Thus, it may free an `ObjectCode` struct wrongly even if there's still a live static object whose info header lies in a mapped section of that `ObjectCode`. This fixes the issue by adding an appropriate check.
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index 6f0ba58abb..9fb91bf3ca 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -1185,11 +1185,17 @@ void freeObjectCode (ObjectCode *oc)
oc->sections[i].mapped_size);
break;
case SECTION_M32:
+ IF_DEBUG(sanity,
+ memset(oc->sections[i].start,
+ 0x00, oc->sections[i].size));
m32_free(oc->sections[i].start,
oc->sections[i].size);
break;
#endif
case SECTION_MALLOC:
+ IF_DEBUG(sanity,
+ memset(oc->sections[i].start,
+ 0x00, oc->sections[i].size));
stgFree(oc->sections[i].start);
break;
default: