Fix a deadlock, and possibly other problems After a bound thread had completed, its TSO remains in the heap until it has been GC'd, although the associated Task is returned to the caller where it is freed and possibly re-used.  
Fix a deadlock, and possibly other problems
After a bound thread had completed, its TSO remains in the heap until
it has been GC'd, although the associated Task is returned to the
caller where it is freed and possibly re-used.  

The bug was that GC was following the pointer to the Task and updating
the TSO field, meanwhile the Task had already been recycled (it was
being used by exitScheduler()). Confusion ensued, leading to a very
occasional deadlock at shutdown, but in principle it could result in
other crashes too.

The fix is to remove the link between the TSO and the Task when the
TSO has completed and the call to schedule() has returned; see
comments in Schedule.c.

acowley/ghc,lukexi/ghc,gcampax/ghc,ghc-android/ghc,gridaphobe/ghc,tjakway/ghcjvm,vikraman/ghc,bitemyapp/ghc,ryantm/ghc,sdiehl/ghc,sgillespie/ghc,hferreiro/replay,oldmanmike/ghc,sdiehl/ghc,sgillespie/ghc,nkaretnikov/ghc,nathyong/microghc-ghc,wxwxwwxxx/ghc,nushio3/ghc,fmthoma/ghc,GaloisInc/halvm-ghc,fmthoma/ghc,elieux/ghc,olsner/ghc,jstolarek/ghc,shlevy/ghc,acowley/ghc,mettekou/ghc,urbanslug/ghc,ghc-android/ghc,mcmaniac/ghc,anton-dessiatov/ghc,ezyang/ghc,sdiehl/ghc,sgillespie/ghc,ml9951/ghc,elieux/ghc,AlexanderPankiv/ghc,oldmanmike/ghc,hferreiro/replay,jstolarek/ghc,lukexi/ghc-7.8-arm64,tjakway/ghcjvm,forked-upstream-packages-for-ghcjs/ghc,green-haskell/ghc,AlexanderPankiv/ghc,tibbe/ghc,spacekitteh/smcghc,siddhanathan/ghc,gridaphobe/ghc,ml9951/ghc,wxwxwwxxx/ghc,ezyang/ghc,nathyong/microghc-ghc,mcmaniac/ghc,mettekou/ghc,TomMD/ghc,shlevy/ghc,tjakway/ghcjvm,tibbe/ghc,green-haskell/ghc,siddhanathan/ghc,nathyong/microghc-ghc,frantisekfarka/ghc-dsi,gcampax/ghc,tibbe/ghc,vikraman/ghc,vikraman/ghc,mfine/ghc,TomMD/ghc,tibbe/ghc,lukexi/ghc,mettekou/ghc,TomMD/ghc,wxwxwwxxx/ghc,jstolarek/ghc,GaloisInc/halvm-ghc,lukexi/ghc,TomMD/ghc,tjakway/ghcjvm,forked-upstream-packages-for-ghcjs/ghc,mcschroeder/ghc,jstolarek/ghc,AlexanderPankiv/ghc,ilyasergey/GHC-XAppFix,gcampax/ghc,siddhanathan/ghc,ghc-android/ghc,GaloisInc/halvm-ghc,mcschroeder/ghc,fmthoma/ghc,mettekou/ghc,gcampax/ghc,elieux/ghc,frantisekfarka/ghc-dsi,green-haskell/ghc,acowley/ghc,urbanslug/ghc,gcampax/ghc,vTurbine/ghc,sgillespie/ghc,sgillespie/ghc,lukexi/ghc-7.8-arm64,ekmett/ghc,hferreiro/replay,urbanslug/ghc,sdiehl/ghc,snoyberg/ghc,GaloisInc/halvm-ghc,ghc-android/ghc,nkaretnikov/ghc,snoyberg/ghc,ryantm/ghc,nkaretnikov/ghc,oldmanmike/ghc,frantisekfarka/ghc-dsi,anton-dessiatov/ghc,ilyasergey/GHC-XAppFix,urbanslug/ghc,vikraman/ghc,mfine/ghc,ilyasergey/GHC-XAppFix,da-x/ghc,wxwxwwxxx/ghc,siddhanathan/ghc,TomMD/ghc,christiaanb/ghc,vTurbine/ghc,snoyberg/ghc,spacekitteh/smcghc,nomeata/ghc,sgillespie/ghc,ilyasergey/GHC-XAppFix,forked-upstream-packages-for-ghcjs/ghc,oldmanmike/ghc,holzensp/ghc,vTurbine/ghc,elieux/ghc,mcschroeder/ghc,vikraman/ghc,mcmaniac/ghc,forked-upstream-packages-for-ghcjs/ghc,nathyong/microghc-ghc,anton-dessiatov/ghc,tjakway/ghcjvm,jstolarek/ghc,wxwxwwxxx/ghc,nkaretnikov/ghc,mfine/ghc,snoyberg/ghc,ezyang/ghc,vikraman/ghc,nushio3/ghc,acowley/ghc,ml9951/ghc,AlexanderPankiv/ghc,vTurbine/ghc,gridaphobe/ghc,tibbe/ghc,da-x/ghc,mfine/ghc,olsner/ghc,hferreiro/replay,green-haskell/ghc,shlevy/ghc,da-x/ghc,oldmanmike/ghc,AlexanderPankiv/ghc,fmthoma/ghc,vTurbine/ghc,hferreiro/replay,christiaanb/ghc,fmthoma/ghc,spacekitteh/smcghc,nathyong/microghc-ghc,gcampax/ghc,anton-dessiatov/ghc,wxwxwwxxx/ghc,bitemyapp/ghc,holzensp/ghc,AlexanderPankiv/ghc,olsner/ghc,mfine/ghc,sdiehl/ghc,gridaphobe/ghc,forked-upstream-packages-for-ghcjs/ghc,mcmaniac/ghc,ryantm/ghc,mfine/ghc,elieux/ghc,siddhanathan/ghc,ezyang/ghc,nushio3/ghc,TomMD/ghc,snoyberg/ghc,nushio3/ghc,TomMD/ghc,gcampax/ghc,ml9951/ghc,ekmett/ghc,bitemyapp/ghc,forked-upstream-packages-for-ghcjs/ghc,lukexi/ghc-7.8-arm64,shlevy/ghc,gridaphobe/ghc,ekmett/ghc,nathyong/microghc-ghc,mettekou/ghc,ml9951/ghc,ekmett/ghc,fmthoma/ghc,mcschroeder/ghc,GaloisInc/halvm-ghc,mettekou/ghc,nomeata/ghc,da-x/ghc,christiaanb/ghc,lukexi/ghc,da-x/ghc,vTurbine/ghc,tjakway/ghcjvm,lukexi/ghc,da-x/ghc,holzensp/ghc,nushio3/ghc,acowley/ghc,forked-upstream-packages-for-ghcjs/ghc,nkaretnikov/ghc,sdiehl/ghc,frantisekfarka/ghc-dsi,mettekou/ghc,GaloisInc/halvm-ghc,AlexanderPankiv/ghc,anton-dessiatov/ghc,mfine/ghc,vikraman/ghc,ml9951/ghc,christiaanb/ghc,ekmett/ghc,bitemyapp/ghc,ezyang/ghc,mcschroeder/ghc,nathyong/microghc-ghc,fmthoma/ghc,hferreiro/replay,lukexi/ghc-7.8-arm64,olsner/ghc,olsner/ghc,shlevy/ghc,vTurbine/ghc,ryantm/ghc,holzensp/ghc,olsner/ghc,nkaretnikov/ghc,GaloisInc/halvm-ghc,olsner/ghc,ml9951/ghc,ml9951/ghc,nushio3/ghc,nushio3/ghc,shlevy/ghc,siddhanathan/ghc,mcschroeder/ghc,lukexi/ghc-7.8-arm64,ghc-android/ghc,tjakway/ghcjvm,nkaretnikov/ghc,gridaphobe/ghc,green-haskell/ghc,snoyberg/ghc,gridaphobe/ghc,anton-dessiatov/ghc,elieux/ghc,ezyang/ghc,oldmanmike/ghc,elieux/ghc,mcschroeder/ghc,shlevy/ghc,urbanslug/ghc,mcmaniac/ghc,christiaanb/ghc,acowley/ghc,spacekitteh/smcghc,anton-dessiatov/ghc,frantisekfarka/ghc-dsi,oldmanmike/ghc,snoyberg/ghc,siddhanathan/ghc,wxwxwwxxx/ghc,christiaanb/ghc,sdiehl/ghc,urbanslug/ghc,hferreiro/replay,nomeata/ghc,acowley/ghc,ryantm/ghc,christiaanb/ghc,ghc-android/ghc,ghc-android/ghc,urbanslug/ghc,nomeata/ghc,nomeata/ghc,spacekitteh/smcghc,ezyang/ghc,da-x/ghc,sgillespie/ghc,bitemyapp/ghc,holzensp/ghc