Commit 9043a400 authored by Simon Marlow's avatar Simon Marlow
Browse files

Fix crashes in hash table scanning with THREADED_RTS

See comments.
parent 5aa9c750
......@@ -105,13 +105,26 @@ scavengeTSO (StgTSO *tso)
Scavenging compact objects
------------------------------------------------------------------------- */
typedef struct {
// We must save gct when calling mapHashTable(), which is compiled
// without GCThread.h and so uses a different calling convention.
// See also GC.c:mark_root where we do a similar thing.
gc_thread *saved_gct;
HashTable *newHash;
} MapHashData;
static void
evacuate_hash_entry(HashTable *newHash, StgWord key, const void *value)
evacuate_hash_entry(MapHashData *dat, StgWord key, const void *value)
StgClosure *p = (StgClosure*)key;
gc_thread *old_gct = gct;
insertHashTable(newHash, (StgWord)p, value);
insertHashTable(dat->newHash, (StgWord)p, value);
static void
......@@ -122,8 +135,11 @@ scavenge_compact(StgCompactNFData *str)
gct->eager_promotion = false;
if (str->hash) {
MapHashData dat;
dat.saved_gct = gct;
HashTable *newHash = allocHashTable();
mapHashTable(str->hash, (void*)newHash, (MapHashFn)evacuate_hash_entry);
dat.newHash = newHash;
mapHashTable(str->hash, (void*)&dat, (MapHashFn)evacuate_hash_entry);
freeHashTable(str->hash, NULL);
str->hash = newHash;
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