[GHC] #11126: Entered absent arg in a Repa program
GHC
ghc-devs at haskell.org
Wed Jan 27 20:33:52 UTC 2016
#11126: Entered absent arg in a Repa program
-------------------------------------+-------------------------------------
Reporter: tuplanolla | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 8.0.1
Component: Compiler | Version: 7.10.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
> So the main question would be: Does the compiler consider unfoldings
when determining whether a value is unused and thus can be replaced by
`absentError`?
I'm very impressed. You've waded though the swamp and indeed I think you
have nailed a culprit. Whether it is ''the'' culprit in the original
program I don't know, but this does look wrong.
Just to lay it out, we have
{{{
f x = let arr2 = ...
let getIt :: Int -> Int
[Unf = { Src=InlineStable, Tmpl=..arr2... }]
getIt n = ...(no arr2)...
in ...
}}}
So `arr2` is not used in `getIt`'s RHS (presumably because `arr2` has
already been inlined into it, but it ''is'' used in `getIt`'s
''unfolding''. Moreover, it's a "stable" unfolding, meaning that it stays
unaffected by transformations in `getIt`'s RHS.
So the following sequence could happen
* Strictness analysis thinks that `arr2` is unused
* Worker-wrapper replaces its binding with `arr2 = absentError "blah"`
* `getIt` is inlined at some call site, and lo! `arr2` is resurrected.
Hmm. Now you have exposed this so well, it's clear that the demand
analyser should take account of the free vars of the unfolding, at least
so far as absence analysis is concerned.
I'll look at how to do that.
Most helpful. Please apply your forensic powers to other bugs :-).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11126#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list