Commit 33d3527b authored by Facundo Domínguez's avatar Facundo Domínguez
Browse files

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
parent 36bba475
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment