Builder Client encounters errors like:
builder-client: fd:11: hGetLine: resource exhausted (Resource temporarily unavailable)
The string resource exhausted
comes from the Show instance for IOErrorType:
The string Resource temporarily unavailable
comes from calling strerror on the underlying SmartOS system:
- https://github.com/ghc/ghc/blob/41f5b7e3e0648302b9c5dc485917a391d21d15a1/libraries/base/Foreign/C/Error.hs#L468
- https://github.com/illumos/illumos-gate/blob/7256a34efe9df75b638b9e812912ef7c5c68e208/usr/src/lib/libc/port/gen/errlist#L50
EAGAIN is mapped to ResourceExhausted in the Foreign C Error mapping in base:
The error message as whole is formatted by the Show instance of IOException:
hGetLine calls hGetLineBuffered calls hGetLineBufferedLoop calls maybeFillReadBuffer which considers anything other than EOF an error:
- http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-IO-Handle-Text.html#hGetLine
- http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-IO-Handle-Text.html#hGetLineBuffered
- http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-IO-Handle-Text.html#hGetLineBufferedLoop
- http://hackage.haskell.org/package/base-4.7.0.0/docs/src/GHC-IO-Handle-Text.html#maybeFillReadBuffer
This flaw might be in using hGetLine on a non-blocking Handle at which point the error lies in ghc-builder and not in hGetLine itself.
This appears to be triggered by getLines in Builder.Command in GHC builder:
It is calling hGetLine on the handles returned from runInteractiveProcess which are binary by default:
References:
Further information:
That last operation blocks in GHCi indicating that it's correcting handling the EAGAIN. DTrace shows that the read call made by hGetline hErr is returning EAGAIN. This is expected.
Something different is occuring when run under SMF. The issue of EAGAIN leaking out as an IOError only occurs when the builder is run under SMF.