<div dir="ltr"><div>I ran 'make accept' on those two tests (they were failing for me locally), and now the build is green again. This was the change:</div><div><a href="https://phabricator.haskell.org/rGHCa138fa1aa9fe2b6499d023ebff4e0fd2f0f1cac8">https://phabricator.haskell.org/rGHCa138fa1aa9fe2b6499d023ebff4e0fd2f0f1cac8</a></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 29, 2015 at 5:35 PM, Sylvain Henry <span dir="ltr"><<a href="mailto:hsyl20@gmail.com" target="_blank">hsyl20@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>It depends on your locale, this explains the different behavior on your local machine.<br><br></div><div>The build machine seems to be using an ASCII locale and GHC wants to print some Unicode characters (the tick and back-tick surrounding types in error messages). Before this patch, Iconv was used to do the conversion from Unicode to ASCII. It seems that it replaces the Unicode ticks with ASCII ticks (i.e. 0xE28098 in UTF-8 into 0x60 and 0xE28099 into 0x27).<br><br>If you enter:<br></div><div>cd ghc/testsuite/tests<br></div><div>grep -rn "match expected type" **/*.stderr <br><br></div><div>You can see that some .stderr have been generated with a ASCII locale and some others with a UTF-8 locale by looking at the ticks. Are the tests expecting ASCII output (e.g. driver/T2507) passing on platforms with UTF-8 locales? The output is not equal to the expected one except if it is converted to ASCII before the comparison.<br><br>With this patch, we don't use Iconv to convert from Unicode to
ASCII because it may not be available in some contexts (docker
containers, initramdisk, etc.). Instead we use the UTF-8 encoder to encode ASCII (ASCII characters are encoded in the same way in ASCII and
in UTF-8) and we don't try to match Unicode only characters to ASCII ones.<br></div><div><br></div><div>Solutions:<br></div><div>1) change our patch to use our method only when Iconv cannot be used.<br></div><div>2) implement the Unicode to ASCII conversion as performed by Iconv<br></div><div>3) change the locale to a UTF-8 one on the build machine ;-)<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>Sylvain<br></div><div><br></div><div><br></div><br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-05-29 3:23 GMT+02:00 Edward Z. Yang <span dir="ltr"><<a href="mailto:ezyang@mit.edu" target="_blank">ezyang@mit.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This commit broke the HM builds: <a href="https://phabricator.haskell.org/B4147" target="_blank">https://phabricator.haskell.org/B4147</a><br>
<br>
When I validate locally, though, it works fine.<br>
<br>
Edward<br>
<br>
Excerpts from git's message of 2015-05-28 18:11:07 -0700:<br>
> Repository : ssh://<a href="http://git@git.haskell.org/ghc" target="_blank">git@git.haskell.org/ghc</a><br>
><br>
> On branch : ghc-7.10<br>
> Link : <a href="http://ghc.haskell.org/trac/ghc/changeset/25b84781ed950d59c7bffb77a576d3c43a883ca9/ghc" target="_blank">http://ghc.haskell.org/trac/ghc/changeset/25b84781ed950d59c7bffb77a576d3c43a883ca9/ghc</a><br>
><br>
> >---------------------------------------------------------------<br>
><br>
> commit 25b84781ed950d59c7bffb77a576d3c43a883ca9<br>
> Author: Austin Seipp <<a href="mailto:austin@well-typed.com" target="_blank">austin@well-typed.com</a>><br>
> Date: Tue May 19 04:56:40 2015 -0500<br>
><br>
> base: fix #10298 & #7695<br>
><br>
> Summary:<br>
> This applies a patch from Reid Barton and Sylvain Henry, which fix a<br>
> disasterous infinite loop when iconv fails to load locale files, as<br>
> specified in #10298.<br>
><br>
> The fix is a bit of a hack but should be fine - for the actual reasoning<br>
> behind it, see `Note [Disaster and iconv]` for more info.<br>
><br>
> In addition to this fix, we also patch up the IO Encoding utilities to<br>
> recognize several variations of the 'ASCII' encoding (including its<br>
> aliases) directly so that GHC can do conversions without iconv. This<br>
> allows a static binary to sit in an initramfs.<br>
><br>
> Authored-by: Reid Barton <<a href="mailto:rwbarton@gmail.com" target="_blank">rwbarton@gmail.com</a>><br>
> Authored-by: Sylvain Henry <<a href="mailto:hsyl20@gmail.com" target="_blank">hsyl20@gmail.com</a>><br>
> Signed-off-by: Austin Seipp <<a href="mailto:austin@well-typed.com" target="_blank">austin@well-typed.com</a>><br>
><br>
> Test Plan: Eyeballed it.<br>
><br>
> Reviewers: rwbarton, hvr<br>
><br>
> Subscribers: bgamari, thomie<br>
><br>
> Differential Revision: <a href="https://phabricator.haskell.org/D898" target="_blank">https://phabricator.haskell.org/D898</a><br>
><br>
> GHC Trac Issues: #10298, #7695<br>
><br>
> (cherry picked from commit e28462de700240288519a016d0fe44d4360d9ffd)<br>
><br>
> >---------------------------------------------------------------<br>
><br>
> 25b84781ed950d59c7bffb77a576d3c43a883ca9<br>
> libraries/base/GHC/IO/Encoding.hs | 14 +++++++++++++-<br>
> libraries/base/GHC/TopHandler.hs | 29 ++++++++++++++++++++++++++++-<br>
> 2 files changed, 41 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/libraries/base/GHC/IO/Encoding.hs b/libraries/base/GHC/IO/Encoding.hs<br>
> index 31683b4..014b61b 100644<br>
> --- a/libraries/base/GHC/IO/Encoding.hs<br>
> +++ b/libraries/base/GHC/IO/Encoding.hs<br>
> @@ -235,7 +235,14 @@ mkTextEncoding e = case mb_coding_failure_mode of<br>
> _ -> Nothing<br>
><br>
> mkTextEncoding' :: CodingFailureMode -> String -> IO TextEncoding<br>
> -mkTextEncoding' cfm enc = case [toUpper c | c <- enc, c /= '-'] of<br>
> +mkTextEncoding' cfm enc<br>
> + -- First, specifically match on ASCII encodings directly using<br>
> + -- several possible aliases (specified by RFC 1345 & co), which<br>
> + -- allows us to handle ASCII conversions without iconv at all (see<br>
> + -- trac #10298).<br>
> + | any (== enc) ansiEncNames = return (UTF8.mkUTF8 cfm)<br>
> + -- Otherwise, handle other encoding needs via iconv.<br>
> + | otherwise = case [toUpper c | c <- enc, c /= '-'] of<br>
> "UTF8" -> return $ UTF8.mkUTF8 cfm<br>
> "UTF16" -> return $ UTF16.mkUTF16 cfm<br>
> "UTF16LE" -> return $ UTF16.mkUTF16le cfm<br>
> @@ -249,6 +256,11 @@ mkTextEncoding' cfm enc = case [toUpper c | c <- enc, c /= '-'] of<br>
> #else<br>
> _ -> Iconv.mkIconvEncoding cfm enc<br>
> #endif<br>
> + where<br>
> + ansiEncNames = -- ASCII aliases<br>
> + [ "ANSI_X3.4-1968", "iso-ir-6", "ANSI_X3.4-1986", "ISO_646.irv:1991"<br>
> + , "US-ASCII", "us", "IBM367", "cp367", "csASCII", "ASCII", "ISO646-US"<br>
> + ]<br>
><br>
> latin1_encode :: CharBuffer -> Buffer Word8 -> IO (CharBuffer, Buffer Word8)<br>
> latin1_encode input output = fmap (\(_why,input',output') -> (input',output')) $ Latin1.latin1_encode input output -- unchecked, used for char8<br>
> diff --git a/libraries/base/GHC/TopHandler.hs b/libraries/base/GHC/TopHandler.hs<br>
> index d7c0038..e725196 100644<br>
> --- a/libraries/base/GHC/TopHandler.hs<br>
> +++ b/libraries/base/GHC/TopHandler.hs<br>
> @@ -157,13 +157,40 @@ real_handler exit se = do<br>
> Just (ExitFailure n) -> exit n<br>
><br>
> -- EPIPE errors received for stdout are ignored (#2699)<br>
> - _ -> case fromException se of<br>
> + _ -> catch (case fromException se of<br>
> Just IOError{ ioe_type = ResourceVanished,<br>
> ioe_errno = Just ioe,<br>
> ioe_handle = Just hdl }<br>
> | Errno ioe == ePIPE, hdl == stdout -> exit 0<br>
> _ -> do reportError se<br>
> exit 1<br>
> + ) (disasterHandler exit) -- See Note [Disaster with iconv]<br>
> +<br>
> +-- don't use errorBelch() directly, because we cannot call varargs functions<br>
> +-- using the FFI.<br>
> +foreign import ccall unsafe "HsBase.h errorBelch2"<br>
> + errorBelch :: CString -> CString -> IO ()<br>
> +<br>
> +disasterHandler :: (Int -> IO a) -> IOError -> IO a<br>
> +disasterHandler exit _ =<br>
> + withCAString "%s" $ \fmt -><br>
> + withCAString msgStr $ \msg -><br>
> + errorBelch fmt msg >> exit 1<br>
> + where msgStr = "encountered an exception while trying to report an exception"<br>
> +<br>
> +{- Note [Disaster with iconv]<br>
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
> +<br>
> +When using iconv, it's possible for things like iconv_open to fail in<br>
> +restricted environments (like an initram or restricted container), but<br>
> +when this happens the error raised inevitably calls `peekCString`,<br>
> +which depends on the users locale, which depends on using<br>
> +`iconv_open`... which causes an infinite loop.<br>
> +<br>
> +This occurrence is also known as tickets #10298 and #7695. So to work<br>
> +around it we just set _another_ error handler and bail directly by<br>
> +calling the RTS, without iconv at all.<br>
> +-}<br>
><br>
><br>
> -- try to flush stdout/stderr, but don't worry if we fail<br>
><br>
--- End forwarded message ---<br>
_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br>
<br></blockquote></div><br></div>