[GHC] #15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Compile-time Unknown/Multiple | crash or panic Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- When trying to build `order-maintenance-0.2.1.0`, GHC 8.4.2-rc1 panics. Its output is as follows: {{{ [ 1 of 21] Compiling Data.Order.Algorithm.Raw ( src/library/Data/Order/Algorithm/Raw.hs, /home/wolfgang/Entwicklung/Haskell/order-maintenance-0.2.1.0/dist- newstyle/build/x86_64-linux/ghc-8.4.1.20180329/order- maintenance-0.2.1.0/build/Data/Order/Algorithm/Raw.o ) [ 2 of 21] Compiling Data.Order.Algorithm.Raw.DietzSleatorAmortizedLog ( src/library/Data/Order/Algorithm/Raw/DietzSleatorAmortizedLog.hs, /home/wolfgang/Entwicklung/Haskell/order-maintenance-0.2.1.0/dist- newstyle/build/x86_64-linux/ghc-8.4.1.20180329/order- maintenance-0.2.1.0/build/Data/Order/Algorithm/Raw/DietzSleatorAmortizedLog.o ) ghc: panic! (the 'impossible' happened) (GHC version 8.4.1.20180329 for x86_64-unknown-linux): StgCmmEnv: variable not found x_a46z local binds for: $tc'Label $tcLabel $tc'Cell $tcCell $trModule $tc'Cell1 $tc'Cell2 $tc'Cell3 $trModule1 $trModule2 $trModule3 $trModule4 $tc'Label1 $tc'Label2 $tc'Label3 $tcCell1 $tcCell2 $tcLabel1 $tcLabel2 lvl_r4UD lvl1_r4UE lvl2_r4UF lvl3_r4UG lvl4_r4UH lvl5_r4UI lvl6_r4UJ lvl7_r4UK lvl8_r4UL lvl9_r4UM lvl10_r4UN lvl11_r4UO lvl12_r4UP lvl13_r4UQ lvl14_r4UR lvl15_r4US lvl16_r4UT lvl17_r4UU $krep_r4UV $krep1_r4UW $krep2_r4UX lvl18_r4UY $krep3_r4UZ $krep4_r4V0 $krep5_r4V1 $krep6_r4V2 $krep7_r4V3 $krep8_r4V4 $krep9_r4V5 lvl19_r4V6 lvl20_r4V7 lvl21_r4V8 lvl22_r4V9 lvl23_r4Va lvl24_r4Vb lvl25_r4Vc ww_s4W2 lwild_s4W3 lwild1_s4W4 noOfLabels_s4W5 noOfLabels1_s4W6 labelMask_s4W7 $wnewAfterCell_s4Wa ww1_s4Wb ipv1_s4Wf wild_s4Wg ds_s4Wh ds2_s4Wi ww2_s4Wk ww3_s4Wl ww4_s4Wn ww5_s4Wo wild1_s4Wq smallGap_s4Wr wild2_s4Ws Call stack: CallStack (from HasCallStack): callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable pprPanic, called at compiler/codeGen/StgCmmEnv.hs:149:9 in ghc:StgCmmEnv Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} The same problem exists with GHC 8.4.1. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sjakobi): * cc: sjakobi (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by sjakobi): * Attachment "T15005.hs" added. One-file repro -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sjakobi): I can reproduce the panic when compiling the attached file with `-O1` or `-O2`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jeltsch): No problems with GHC 8.2.2, by the way. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sjakobi): I cannot reproduce the panic with ghc-HEAD (`c2f90c84e`) or ghc v8.5.20180306 from hvr's PPA. It is interesting (but possibly unrelated) that the testsuite for `order- maintenance` fails when built with ghc-HEAD. With ghc-8.2.2 it passes. {{{ ~/tmp/order-maintenance-0.2.1.0 $ cabal new-test -w ~/src/ghc/inplace/bin /ghc-stage2 -O1 --allow-newer Build profile: -w ghc-8.5.20180402 -O1 In order, the following will be built (use -v for more details): - order-maintenance-0.2.1.0 (test:tests) (first run) Preprocessing test suite 'tests' for order-maintenance-0.2.1.0.. Building test suite 'tests' for order-maintenance-0.2.1.0.. [1 of 1] Compiling Main ( /home/simon/tmp/order- maintenance-0.2.1.0/dist-newstyle/build/x86_64-linux/ghc-8.5.20180402 /order-maintenance-0.2.1.0/t/tests/build/testsStub/testsStub- tmp/testsStub.hs, /home/simon/tmp/order-maintenance-0.2.1.0/dist- newstyle/build/x86_64-linux/ghc-8.5.20180402/order- maintenance-0.2.1.0/t/tests/build/testsStub/testsStub-tmp/Main.o ) Linking /home/simon/tmp/order-maintenance-0.2.1.0/dist- newstyle/build/x86_64-linux/ghc-8.5.20180402/order- maintenance-0.2.1.0/t/tests/build/testsStub/testsStub ... Running 1 test suites... Test suite tests: RUNNING... Test case Dumb vs. Dietz and Sleator O(log n) amortized time: Fail "(after 14 tests and 5 shrinks):Exception: Map.!: given key is not an element in the map CallStack (from HasCallStack): error, called at libraries/containers/Data/Map/Internal.hs:610:17 in containers-0.5.11.0:Data.Map.InternalnewMinimum -> x_1, newAfter x_1 -> x_2, newMinimum -> x_3, newBefore x_2 -> x_4, newAfter x_4 -> x_5, delete x_1, newBefore x_1 -> x_7" Test suite tests: FAIL ... }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): Some notes: * This bug was introduced in commit 0e953da147c405648356f75ee67eda044fffad49 (Implement a dedicated exitfication pass #14152) * This bug later disappeared after commit 06366890ba77c20198d7fccc870083b0bbfb1b11 (Fix the lone-variable case in callSiteInline) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): The bug is in this line of `Exitify` {{{ -- The possible arguments of this exit join point args = filter (`elemVarSet` fvs) captured }}} You have to do at least `map zapStableUnfolding` over args. Consider {{{ joinrec j x = let {-# INLINE foo #-} foo y = blah in case x of True -> j2 foo (h x) False -> ...j.... }}} We are going to exitify the True branch of the 'case x'. But 'foo' is captured, so we get {{{ join exit foo x = jump j2 foo (h x) in joinrec j x = let {-# INLINE foo #-} foo y = blah in case x of True -> jump exit foo x False -> ...j.... }}} But we must zap `foo`'s unfolding when we lambda-abstract it! In effect, the lambda-bound `foo` is an entirely new `foo`, unrelated to the original. Actually, arguably we should give the lambda-bound foo `vanillaIdInfo`. We do this in `SetLevels.abstractVars`. I think that'd be safer. We don't seem to have a function `zapAllIdInfo` but we probably should. Over to you. Please include some version of this explanation, of course. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.3 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: nomeata (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.2 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * milestone: 8.4.3 => 8.4.2 Comment: I'm a bit confused as to what the current status of this ticket is. comment:5 identifies a commit (not yet merged into GHC 8.4.2) which apparently fixes this issue, but simonpj suggests in comment:6 that there is more to be done. Either way, we should backport //some// sort of fix to 8.4.2. Thoughts, noneata? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.4.2 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata): Thanks for bringing this to my attention. The mentioned commit probably only hides the issue, but does not fix it, and it needs to be fixed as Simon describes. `T15005.hs` produces the test case on `ghc-8.4`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile
order-maintenance-0.2.1.0
-------------------------------------+-------------------------------------
Reporter: jeltsch | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.4.2
Component: Compiler | Version: 8.4.2-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Joachim Breitner

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: 8.4.2 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4582 Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: new => patch * differential: => Phab:D4582 Comment: Simons diagnosis is correct: I implemented it, and it fixes the bug, even on the 8.4 branch. If Harbormaster is happy with my patch at Phab:D4582 I will push it to master and request this to be merged into 8.4. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile
order-maintenance-0.2.1.0
-------------------------------------+-------------------------------------
Reporter: jeltsch | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone: 8.4.2
Component: Compiler | Version: 8.4.2-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Compile-time | Unknown/Multiple
crash or panic | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D4582
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Joachim Breitner

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.4.2 Component: Compiler | Version: 8.4.2-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4582 Wiki Page: | -------------------------------------+------------------------------------- Changes (by nomeata): * status: patch => merge Comment: Pushed as 3cfb12d8adac37e5565d66fd173e4648cc041e65, should be merged. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15005: GHC fails with “StgCmmEnv: variable not found” when trying to compile order-maintenance-0.2.1.0 -------------------------------------+------------------------------------- Reporter: jeltsch | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.4.2 Component: Compiler | Version: 8.4.2-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple crash or panic | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4582 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.4` as 2f5b97c37dbc9708e7a33b4e36f66a12b32ee09f. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15005#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC