inspecting the source of readProcessWithExitCode yields an obvious explanation to the MVar problem, but I don't understand why hGetContents is so offended.
I think last time I looked into this there was no normalization of package.conf data; if it was read in in a particular encoding, it was stored in that encoding and you can get an exception trying to dump it in a different encoding. Certainly I have found ISO8859-1 encoded text in my package.conf.d/* files, when I would expect (and was configured for) UTF-8. This also suggests that ISO8859-1 text in a *.cabal file would remain ISO8859-1 in the resulting package.conf file even if UTF-8 encoding was active at the time.
--