ghc 8.4.1 and trac 13930

Simon Peyton Jones simonpj at microsoft.com
Wed May 2 08:24:15 UTC 2018


|  I recently noticed that with -O1, ghc was optimizing some code
|  
|      if Trace.traceShowId "b" $ True
|          then ...
|          else ...
|  
|  to always evaluate the 'else' branch.  

Are you certain this is #13930?  I don't see an obvious connection.  It seems really really terrible to "optimise" True to False!

I think #13930 was fixed by #5129, which in turn was about discarding a call to 'evaluate'.  That is different to turning True to False.

But there's probably some more complicated context to your use-case that means my understanding is faulty.

If you are confident that it's securely fixed, well and good. But when bugs disappear I always worry that they are still there, just concealed by some other change.

Simon


|  -----Original Message-----
|  From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Evan
|  Laforge
|  Sent: 02 May 2018 04:10
|  To: ghc-devs at haskell.org
|  Subject: ghc 8.4.1 and trac 13930
|  
|  I recently noticed that with -O1, ghc was optimizing some code
|  
|      if Trace.traceShowId "b" $ True
|          then return $ Left $ Serialize.BadMagic (Serialize.magicBytes
|  magic) file_magic
|          else first Serialize.UnserializeError <$> Exception.evaluate
|  (Serialize.decode rest)
|  
|  to always evaluate the 'else' branch.  This is fixed in 8.4.2, so I'm
|  pretty sure it's https://ghc.haskell.org/trac/ghc/ticket/13930
|  
|  I assume there's no point trying to get a minimal reproduction, since
|  it's a known issue and fixed.  Still,
|  https://downloads.haskell.org/~ghc/8.4.2/docs/html/users_guide/8.4.2-
|  notes.html
|  says "incorrectly optimised, resulting in space leaks".
|  
|  Maybe it should instead say "incorrectly optimised, resulting in
|  taking the wrong branch in 'if' expressions"?  That's a bit more
|  alarming, and is a stronger "upgrade to 8.4.2" signal.
|  _______________________________________________
|  ghc-devs mailing list
|  ghc-devs at haskell.org
|  http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs


More information about the ghc-devs mailing list