[Haskell-cafe] GHC.Conc.threadStatus - documentation of ThreadDied :: ThreadStatus

Olaf Klinke olf at aatal-apotheke.de
Tue Mar 8 07:06:18 UTC 2022


On Mon, 2022-03-07 at 23:04 -0500, Ben Gamari wrote:
> Olaf Klinke <olf at aatal-apotheke.de> writes:
> 
> > Dear Cafe, 
> > 
> > I had expected to see ThreadDied in the small example below.  
> > But when I compile with 
> > ghc --make -threaded -with-rtsopts=-N2
> > The output is:
> > 
> > threadStatus: user error (child thread is crashing!)
> > The status of my child is:
> > ThreadFinished
> > 
> > The output is not really a lie. But how do I determine whether a child
> > thread has exited normally or not? Wouldn't you say a call to fail (or
> > any other throwIO) should count as ThreadDied? 
> > 
> > The documentation of GHC.Conc.forkIO says:
> > "... passes all other exceptions to the uncaught exception handler."
> > and the documentation for GHC.Conc.ThreadStatus says:
> > ThreadDied -- the thread received an uncaught exception
> > 
> > One can provoke ThreadDied by using throwTo from the parent thread. So
> > the emphasis in the documentation of ThreadDied should be on the word
> > "received".
> > This is a case of misleading documentation, in my humble opinion.   
> > The constructor should not be named ThreadDied because that suggests
> > inclusion of internal reasons. 
> > 
> Thanks for reporting this, Olaf! Could you open a GHC ticket? [1]
> 
> Cheers,
> 
> - Ben
> 
> [1] https://gitlab.haskell.org/ghc/ghc/-/issues/new

Opened as 
https://gitlab.haskell.org/ghc/ghc/-/issues/21195

Regards
Olaf





More information about the Haskell-Cafe mailing list