Commit ae03da75 authored by Simon Marlow's avatar Simon Marlow

during shutdown, only free the heap if we waited for foreign calls to exit

parent 9cf95228
......@@ -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 */
......
......@@ -213,10 +213,10 @@ exitStorage (void)
}
void
freeStorage (void)
freeStorage (rtsBool free_heap)
{
stgFree(generations);
freeAllMBlocks();
if (free_heap) freeAllMBlocks();
#if defined(THREADED_RTS)
closeMutex(&sm_mutex);
#endif
......
......@@ -19,7 +19,7 @@
void initStorage(void);
void exitStorage(void);
void freeStorage(void);
void freeStorage(rtsBool free_heap);
/* -----------------------------------------------------------------------------
Storage manager state
......
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