<div dir="ltr">do you use a deepSeq when catching errors from a pure computation? Or is it in a context where you know the value should be treated strictly?  (<a href="https://github.com/ndmitchell/shake/issues/216">https://github.com/ndmitchell/shake/issues/216</a> seems to be the ticket in question, but since i dont have a 7.10 handy and the test suite seems to be quite large, itd be super helpful if you could point out which tests are failing).<div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 19, 2015 at 8:12 PM, Neil Mitchell <span dir="ltr"><<a href="mailto:ndmitchell@gmail.com" target="_blank">ndmitchell@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Since I won't have access to my development computer during work hours<br>
tomorrow, I generated complete Core for both versions and put them in<br>
<a href="http://community.haskell.org/~ndm/temp/core.zip" target="_blank">http://community.haskell.org/~ndm/temp/core.zip</a>.<br>
<br>
Thanks, Neil<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, Mar 20, 2015 at 12:01 AM, Neil Mitchell <<a href="mailto:ndmitchell@gmail.com">ndmitchell@gmail.com</a>> wrote:<br>
> More delving later, it seems the incorrect optimized version has been<br>
> turned into:<br>
><br>
> case (\ _ [Occ=Dead, OS=OneShot] -> error "here") of _ [Occ=Dead] {}<br>
><br>
> While the working one has been turned into:<br>
><br>
> errorFunc argument realWorldToken<br>
><br>
> where errorFunc _ = error "here"<br>
><br>
> I'm not familiar with case ... of _ {} - what does it mean when there<br>
> are no alternatives to the case? And why isn't case on a literal<br>
> lambda optimised out? Is it the OneShot annotation (perhaps coming<br>
> from the state hack?)<br>
><br>
> The full trace is at<br>
> <a href="https://gist.github.com/ndmitchell/b222e04eb0c3a397c758" target="_blank">https://gist.github.com/ndmitchell/b222e04eb0c3a397c758</a>. I've uploaded<br>
> bad (optimises the error out) and good (works as expected) versions of<br>
> the Core. The summary files are the subexpression that changed making<br>
> a single difference (moving a monomorphic NOINLINE function from one<br>
> module to another) plus the handful of functions they depend on, which<br>
> I've reformatted/inlined/simplified to produce the expressions above.<br>
> The full versions are the entire -ddump-simpl output from about<br>
> halfway through the build, starting when the differences occur - let<br>
> me know if you need further back. The dodgy function is "exec".<br>
><br>
> Thanks, Neil<br>
><br>
> On Thu, Mar 19, 2015 at 11:07 PM, Neil Mitchell <<a href="mailto:ndmitchell@gmail.com">ndmitchell@gmail.com</a>> wrote:<br>
>> Herbert, thanks for the list of patches, nothing obvious there - my<br>
>> best guess is it's something incredibly sensitive and it only needs<br>
>> the tiniest change anywhere to make it happen. Things like moving<br>
>> NOINLINE monomorphic-type definitions from one module to another are<br>
>> causing the bug to appear/disappear, which isn't what I'd expect.<br>
>><br>
>> Simon, changing from error to error in IO causes the bug to disappear,<br>
>> but then so do most things. The error return type is type IO (), so I<br>
>> suspect that forces it to be raised at the right place - but it's<br>
>> certainly one of the possibilities for what is going wrong. Diffing<br>
>> the Core is a great idea.<br>
>><br>
>> I'll keep reducing and see what I get to. Given the sensitivity of the<br>
>> bug, I'm sure a NOINLINE on an out-of-the-way function will make it go<br>
>> away, so I can easily fix Shake itself - so I'm more tracking it down<br>
>> from the point of GHC now.<br>
>><br>
>> Thanks, Neil<br>
>><br>
>><br>
>> On Wed, Mar 18, 2015 at 5:04 PM, Simon Peyton Jones<br>
>> <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br>
>>> I'm really sorry but I can't think of anything.  Sounds horrible.<br>
>>><br>
>>> If you throw exceptions using 'error' (not in IO), then you are of course vulnerable to strictness changes.  If the thing isn't actually evaluated inside the catch block, you won't see the exception.  But I'm sure you've thought of that.<br>
>>><br>
>>> I'd experiment with one of the smaller changes you describe, such as adding a putStrLn, and comparing Core, before and after.  Switching off -O will make a huge difference, so hard to compare.  Turning off the state hack will have a more global effect.  But the other changes sound more pin-point and hence the differences will be smaller.<br>
>>><br>
>>> Simon<br>
>>><br>
>>> |  -----Original Message-----<br>
>>> |  From: ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org">ghc-devs-bounces@haskell.org</a>] On Behalf Of Neil<br>
>>> |  Mitchell<br>
>>> |  Sent: 18 March 2015 15:33<br>
>>> |  To: <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
>>> |  Subject: Shake fails test with GHC 7.10 RC3<br>
>>> |<br>
>>> |  Hi,<br>
>>> |<br>
>>> |  Testing GHC 7.10 RC3 I've found a bug where Shake seems to catch the<br>
>>> |  wrong exception in the wrong place. It's only hit by one of my tests,<br>
>>> |  and I've managed to isolate it to a fragment of code with no<br>
>>> |  unsafePerformIO, that throws exceptions using error (so not in IO), and<br>
>>> |  operates in IO. Turning off the stack hack makes the bug go away, but<br>
>>> |  then so does -O0, marking one of the functions it calls NOINLINE, or<br>
>>> |  moving an INLINE function it calls to a different module, or adding a<br>
>>> |  putStrLn under a catch block - it's very sensitive to the exact<br>
>>> |  conditions. This test and this exact code worked fine with GHC 7.10<br>
>>> |  RC2.<br>
>>> |<br>
>>> |  I was wondering if there have been any state hack related changes or<br>
>>> |  other potentially dangerous optimisation changes since RC2? I'll<br>
>>> |  continue to try reducing the bug, but it's somewhat difficult as the<br>
>>> |  larger system is quite big, and the code is very sensitive.<br>
>>> |<br>
>>> |  Thanks, Neil<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>
> On Thu, Mar 19, 2015 at 11:24 PM, Simon Peyton Jones<br>
> <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br>
>> Thanks!  I think a -ddump-simpl before and after the smallest change the makes the difference would be illuminating.<br>
>><br>
>> Simon<br>
>><br>
>> | -----Original Message-----<br>
>> | From: Neil Mitchell [mailto:<a href="mailto:ndmitchell@gmail.com">ndmitchell@gmail.com</a>]<br>
>> | Sent: 19 March 2015 23:07<br>
>> | To: Simon Peyton Jones<br>
>> | Cc: <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
>> | Subject: Re: Shake fails test with GHC 7.10 RC3<br>
>> |<br>
>> | Herbert, thanks for the list of patches, nothing obvious there - my<br>
>> | best guess is it's something incredibly sensitive and it only needs<br>
>> | the tiniest change anywhere to make it happen. Things like moving<br>
>> | NOINLINE monomorphic-type definitions from one module to another are<br>
>> | causing the bug to appear/disappear, which isn't what I'd expect.<br>
>> |<br>
>> | Simon, changing from error to error in IO causes the bug to disappear,<br>
>> | but then so do most things. The error return type is type IO (), so I<br>
>> | suspect that forces it to be raised at the right place - but it's<br>
>> | certainly one of the possibilities for what is going wrong. Diffing<br>
>> | the Core is a great idea.<br>
>> |<br>
>> | I'll keep reducing and see what I get to. Given the sensitivity of the<br>
>> | bug, I'm sure a NOINLINE on an out-of-the-way function will make it go<br>
>> | away, so I can easily fix Shake itself - so I'm more tracking it down<br>
>> | from the point of GHC now.<br>
>> |<br>
>> | Thanks, Neil<br>
>> |<br>
>> |<br>
>> | On Wed, Mar 18, 2015 at 5:04 PM, Simon Peyton Jones<br>
>> | <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br>
>> | > I'm really sorry but I can't think of anything.  Sounds horrible.<br>
>> | ><br>
>> | > If you throw exceptions using 'error' (not in IO), then you are of<br>
>> | course vulnerable to strictness changes.  If the thing isn't actually<br>
>> | evaluated inside the catch block, you won't see the exception.  But I'm<br>
>> | sure you've thought of that.<br>
>> | ><br>
>> | > I'd experiment with one of the smaller changes you describe, such as<br>
>> | adding a putStrLn, and comparing Core, before and after.  Switching off -<br>
>> | O will make a huge difference, so hard to compare.  Turning off the state<br>
>> | hack will have a more global effect.  But the other changes sound more<br>
>> | pin-point and hence the differences will be smaller.<br>
>> | ><br>
>> | > Simon<br>
>> | ><br>
>> | > |  -----Original Message-----<br>
>> | > |  From: ghc-devs [mailto:<a href="mailto:ghc-devs-bounces@haskell.org">ghc-devs-bounces@haskell.org</a>] On Behalf Of<br>
>> | Neil<br>
>> | > |  Mitchell<br>
>> | > |  Sent: 18 March 2015 15:33<br>
>> | > |  To: <a href="mailto:ghc-devs@haskell.org">ghc-devs@haskell.org</a><br>
>> | > |  Subject: Shake fails test with GHC 7.10 RC3<br>
>> | > |<br>
>> | > |  Hi,<br>
>> | > |<br>
>> | > |  Testing GHC 7.10 RC3 I've found a bug where Shake seems to catch the<br>
>> | > |  wrong exception in the wrong place. It's only hit by one of my<br>
>> | tests,<br>
>> | > |  and I've managed to isolate it to a fragment of code with no<br>
>> | > |  unsafePerformIO, that throws exceptions using error (so not in IO),<br>
>> | and<br>
>> | > |  operates in IO. Turning off the stack hack makes the bug go away,<br>
>> | but<br>
>> | > |  then so does -O0, marking one of the functions it calls NOINLINE, or<br>
>> | > |  moving an INLINE function it calls to a different module, or adding<br>
>> | a<br>
>> | > |  putStrLn under a catch block - it's very sensitive to the exact<br>
>> | > |  conditions. This test and this exact code worked fine with GHC 7.10<br>
>> | > |  RC2.<br>
>> | > |<br>
>> | > |  I was wondering if there have been any state hack related changes or<br>
>> | > |  other potentially dangerous optimisation changes since RC2? I'll<br>
>> | > |  continue to try reducing the bug, but it's somewhat difficult as the<br>
>> | > |  larger system is quite big, and the code is very sensitive.<br>
>> | > |<br>
>> | > |  Thanks, Neil<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>
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>
</div></div></blockquote></div><br></div>