X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FRtsStartup.c;h=d7a8d954a27cd7c794c91db74046f1bc5b04b79a;hb=401140734891ca804c336122581743251d61b3a6;hp=f0b2598734505d098f6ad712424847028f85fb09;hpb=849ce0c790ae8eeb636c722149993e7fb9766c9d;p=ghc-hetmet.git diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c index f0b2598..d7a8d95 100644 --- a/rts/RtsStartup.c +++ b/rts/RtsStartup.c @@ -184,7 +184,9 @@ hs_init(int *argc, char **argv[]) getStablePtr((StgPtr)runSparks_closure); getStablePtr((StgPtr)ensureIOManagerIsRunning_closure); +#ifndef mingw32_HOST_OS getStablePtr((StgPtr)runHandlers_closure); +#endif /* initialise the shared Typeable store */ initGlobalStore(); @@ -370,7 +372,7 @@ hs_exit_(rtsBool wait_foreign) /* stop the ticker */ stopTimer(); - exitTimer(); + exitTimer(wait_foreign); // set the terminal settings back to what they were #if !defined(mingw32_HOST_OS) @@ -448,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 */