X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=rts%2FRtsStartup.c;fp=rts%2FRtsStartup.c;h=d7a8d954a27cd7c794c91db74046f1bc5b04b79a;hp=b0cddbd18fa99343f5308343191b8f92fb78ffab;hb=ae03da75d16d5d6e00c6f12102846509060a1138;hpb=9cf9522864e8110f5c033d58d9d5d867c371a4b6 diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index b0cddbd..d7a8d95 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -450,8 +450,11 @@ hs_exit_(rtsBool wait_foreign) /* free hash table storage */ exitHashTable(); - // Finally, free all our storage - freeStorage(); + // Finally, free all our storage. However, we only free the heap + // memory if we have waited for foreign calls to complete; + // otherwise a foreign call in progress may still be referencing + // heap memory (e.g. by being passed a ByteArray#). + freeStorage(wait_foreign); #if defined(DEBUG) /* and shut down the allocator debugging */