summaryrefslogtreecommitdiff
path: root/rts/StaticPtrTable.c
diff options
context:
space:
mode:
authorFacundo Domínguez <facundo.dominguez@tweag.io>2016-09-01 16:31:26 -0300
committerFacundo Domínguez <facundo.dominguez@tweag.io>2016-09-02 09:59:18 -0300
commit33d3527b7c6578bcb6dfa4d0657d0333de36d2df (patch)
treeee7a4532545919eac6a47f39c607970ea57a30c2 /rts/StaticPtrTable.c
parent36bba475130509d6fe531277770b4c8226361961 (diff)
downloadhaskell-33d3527b7c6578bcb6dfa4d0657d0333de36d2df.tar.gz
Protect StablPtr dereference with the StaticPtr table lock.
Summary: Also comment on the need to use stgMallocBytes in StaticPtrTable.c. Test Plan: ./validate Reviewers: erikd, austin, bgamari, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2506
Diffstat (limited to 'rts/StaticPtrTable.c')
-rw-r--r--rts/StaticPtrTable.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/rts/StaticPtrTable.c b/rts/StaticPtrTable.c
index f7fe06647a..57ade5bafb 100644
--- a/rts/StaticPtrTable.c
+++ b/rts/StaticPtrTable.c
@@ -43,6 +43,9 @@ void hs_spt_insert(StgWord64 key[2],void *spe_closure) {
#endif
}
+ // Cannot remove this indirection yet because getStablePtr()
+ // might return NULL, in which case hs_spt_lookup() returns NULL
+ // instead of the actual closure pointer.
StgStablePtr * entry = stgMallocBytes( sizeof(StgStablePtr)
, "hs_spt_insert: entry"
);
@@ -72,8 +75,8 @@ StgPtr hs_spt_lookup(StgWord64 key[2]) {
if (spt) {
ACQUIRE_LOCK(&spt_lock);
const StgStablePtr * entry = lookupHashTable(spt, (StgWord)key);
- RELEASE_LOCK(&spt_lock);
const StgPtr ret = entry ? deRefStablePtr(*entry) : NULL;
+ RELEASE_LOCK(&spt_lock);
return ret;
} else
return NULL;