work around ghc segfault
authorJoey Hess <joeyh@joeyh.name>
Fri, 30 Dec 2016 22:14:19 +0000 (18:14 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 30 Dec 2016 22:14:19 +0000 (18:14 -0400)
commit23d71423e19d9eb9f940b3011bbdabe0bf80aca6
tree758a0883e82709e682d85627310b1692efa764a1
parent1c744b951263774f12f3bf028aeb5f98f29ad816
work around ghc segfault

hSetEncoding of a closed handle segfaults.
https://ghc.haskell.org/trac/ghc/ticket/7161

8484c0c1976b2daa4be674b09f6f54c15c746aa6 introduced the crash.
In particular, stdin may get closed (by eg, getContents) and then trying
to set its encoding will crash. We didn't need to adjust stdin's
encoding anyway, but only stderr, to work around
https://github.com/yesodweb/persistent/issues/474

Thanks to Mesar Hameed for assistance related to reproducing this bug.
Database/Handle.hs
Utility/FileSystemEncoding.hs