[commit: ghc] master: Protect StablPtr dereference with the StaticPtr table lock. (33d3527)
git at git.haskell.org
git at git.haskell.org
Fri Sep 2 12:59:27 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/33d3527b7c6578bcb6dfa4d0657d0333de36d2df/ghc
>---------------------------------------------------------------
commit 33d3527b7c6578bcb6dfa4d0657d0333de36d2df
Author: Facundo DomÃnguez <facundo.dominguez at tweag.io>
Date: Thu Sep 1 16:31:26 2016 -0300
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
>---------------------------------------------------------------
33d3527b7c6578bcb6dfa4d0657d0333de36d2df
rts/StaticPtrTable.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/rts/StaticPtrTable.c b/rts/StaticPtrTable.c
index f7fe066..57ade5b 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;
More information about the ghc-commits
mailing list