X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsStartup.c;h=d7a8d954a27cd7c794c91db74046f1bc5b04b79a;hb=13346da217137e4efb6cf14657960c75a23251ad;hp=b0cddbd18fa99343f5308343191b8f92fb78ffab;hpb=243c043271d295c98ac0f69b4bc8fccca3b61d2d;p=ghc-hetmet.git 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 */