[GHC] #11155: Trivial error thunk gives "undefined reference to stg_ap_0_upd_info"
#11155: Trivial error thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This error popped up when Alan was coding the solution for #11028. The error is utterly unrelated to what Alan was working on. Here's a reproducer {{{ {-# OPTIONS_GHC -O -fno-full-laziness #-} module Main where foo :: Bool {-# NOINLINE foo #-} foo = error "rk" bar x = let t :: Char t = case foo of { True -> 'v'; False -> 'y' } in [t] main = print (bar ()) }}} Just compile that and you get {{{ Foo.o: In function `c1Sm_info': (.text+0x29a): undefined reference to `stg_ap_0_upd_info' }}} Why do we get that unresolved symbol? The STG code for `bar` looks like {{{ Main.bar :: forall t_aup. t_aup -> [GHC.Types.Char] [GblId, Arity=1, Str=DmdType <L,A>m2, Unf=OtherCon []] = \r srt:SRT:[rf :-> Main.foo] [x_s1RR] let { sat_s1RT [Occ=Once] :: GHC.Types.Char [LclId, Str=DmdType] = \u srt:SRT:[rf :-> Main.foo] [] Main.foo; } in : [sat_s1RT GHC.Types.[]]; }}} Look at that: an updatable thunk saying `sat_s1RT = Main.foo`! The error message is terrible, but the problem is a thunk whose only payload is a single variable. Why does that happen? The Core is {{{ bar = \ (@ t_aup) _ -> let t::Char = case foo of wild_00 { } in : @ Char t ([] @ Char) }}} The `case` is needed to change `foo`'s type from `Bool` to `Char`. The Core-to-STG pass drops the empty case alternatives as useless (rightly), but leaves a bare variable as the RHS, which confuses the code generator. We should clearly substitute `Main.foo` for `t`, either in Core-to-STG, or during code generation. Why hasn't this happened before now? It is quite hard to provoke, because floating the thunk for `t` to top level stops it happening. So it only happens if you switch off full laziness (as my test case here does), or if some very delicate inlining happens after the last float-out. The latter is very rare, but it's what happened to Alan. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by hvr): * priority: normal => high Comment: Fyi, I'm seeing this during GHC building as well (which makes the current Ubuntu PPA nightlies fail): {{{ ... AR compiler/stage2/build/libHSghc-7.11.20151202.a HC [stage 1] compiler/stage2/build/libHSghc-7.11.20151202-ghc7.11.20151202.so /usr/bin/ar: creating compiler/stage2/build/libHSghc-7.11.20151202.a Warning: -rtsopts and -with-rtsopts have no effect with -shared. Call hs_init_ghc() from your main() function to set these options. "rm" -f compiler/stage2/build/libHSghc-7.11.20151202.a.contents HC [stage 1] ghc/stage2/build/GhciTags.dyn_o HC [stage 1] ghc/stage2/build/InteractiveUI.dyn_o HC [stage 1] ghc/stage2/build/Main.dyn_o HC [stage 1] ghc/stage2/build/tmp/ghc-stage2 Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. /«PKGBUILDDIR»/compiler/stage2/build/libHSghc-7.11.20151202-ghc7.11.20151202.so: undefined reference to `stg_ap_0_upd_info' collect2: ld returned 1 exit status `gcc' failed in phase `Linker'. (Exit code: 1) make[3]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make[2]: *** [all] Error 2 make[2]: Leaving directory `/«PKGBUILDDIR»' make[1]: *** [override_dh_auto_build] Error 2 make[1]: Leaving directory `/«PKGBUILDDIR»' make: *** [build] Error 2 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by alanz): * cc: alanz (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"1c9fd3f1c5522372fcaf250c805b959e8090a62c/ghc" 1c9fd3f1/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="1c9fd3f1c5522372fcaf250c805b959e8090a62c" Case-of-empty-alts is trivial (Trac #11155) As you'll see from Trac #11155, the code generator was confused by a binding let x = y in .... Why did that happen? Because of a (case y of {}) expression on the RHS. The right thing is just to expand what a "trivial" expression is. See Note [Empty case is trivial] in CoreUtils. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => simplCore/should_compile/T11155 * resolution: => fixed Comment: I claim this is fixed. Alan, Herbert, does this fix the manifestations you see? I'll close it meanwhile. Simon -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alanz): Yes, the linker error is gone for haddock in D1558. Thanks. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: high | Milestone: Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by hvr): I don't see the manifestation either anymore (i.e. the PPA builds work again now) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by gridaphobe): I just ran into this (or a similar issue) when building GHC (9b6820cdd6bac8b8346be48224627e3feefa9036) on OSX. This is a clean build with the default settings, and it fails at the very last step of stage 2. {{{ HC [stage 1] ghc/stage2/build/tmp/ghc-stage2 Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1s8Z_info in UI.dyn_o _s1s9w_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by wereHamster): Ran into this trying to build HEAD today on Mac OS X 10.11.3. But a slightly different message: {{{ Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1xPf_info in UI.dyn_o _s1xQA_info in UI.dyn_o _s1xZU_info in UI.dyn_o _s1y0r_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:10> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by George): I ran into this today building 8.0.1 rc3 on Mac 10.11.4 with XCode 7.3 invoking with "make -j5": Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main. Call hs_init_ghc() from your main() function to set these options. Undefined symbols for architecture x86_64: "_stg_sel_17_upd_info", referenced from: _s1xEL_info in UI.dyn_o _s1xG6_info in UI.dyn_o _s1xPC_info in UI.dyn_o _s1xQ9_info in UI.dyn_o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) `gcc' failed in phase `Linker'. (Exit code: 1) make[1]: *** [ghc/stage2/build/tmp/ghc-stage2] Error 1 make: *** [all] Error 2 bash-3.2$ -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:11> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: closed => new * resolution: fixed => @@ -4,1 +4,1 @@ - {{{ + {{{#!hs New description: This error popped up when Alan was coding the solution for #11028. The error is utterly unrelated to what Alan was working on. Here's a reproducer {{{#!hs {-# OPTIONS_GHC -O -fno-full-laziness #-} module Main where foo :: Bool {-# NOINLINE foo #-} foo = error "rk" bar x = let t :: Char t = case foo of { True -> 'v'; False -> 'y' } in [t] main = print (bar ()) }}} Just compile that and you get {{{ Foo.o: In function `c1Sm_info': (.text+0x29a): undefined reference to `stg_ap_0_upd_info' }}} Why do we get that unresolved symbol? The STG code for `bar` looks like {{{ Main.bar :: forall t_aup. t_aup -> [GHC.Types.Char] [GblId, Arity=1, Str=DmdType <L,A>m2, Unf=OtherCon []] = \r srt:SRT:[rf :-> Main.foo] [x_s1RR] let { sat_s1RT [Occ=Once] :: GHC.Types.Char [LclId, Str=DmdType] = \u srt:SRT:[rf :-> Main.foo] [] Main.foo; } in : [sat_s1RT GHC.Types.[]]; }}} Look at that: an updatable thunk saying `sat_s1RT = Main.foo`! The error message is terrible, but the problem is a thunk whose only payload is a single variable. Why does that happen? The Core is {{{ bar = \ (@ t_aup) _ -> let t::Char = case foo of wild_00 { } in : @ Char t ([] @ Char) }}} The `case` is needed to change `foo`'s type from `Bool` to `Char`. The Core-to-STG pass drops the empty case alternatives as useless (rightly), but leaves a bare variable as the RHS, which confuses the code generator. We should clearly substitute `Main.foo` for `t`, either in Core-to-STG, or during code generation. Why hasn't this happened before now? It is quite hard to provoke, because floating the thunk for `t` to top level stops it happening. So it only happens if you switch off full laziness (as my test case here does), or if some very delicate inlining happens after the last float-out. The latter is very rare, but it's what happened to Alan. -- Comment: The fix mentioned in comment:4 is present on the `ghc-8.0` branch as 1c9fd3f1c5522372fcaf250c805b959e8090a62c. Indeed it seems that something is still amiss here. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:12> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * priority: high => highest -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:13> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed Comment: This actually appears to be a much different issue from that originally reported in this ticket as the symbol in question are update closures instead of zero-arity applications. Let's track this new issue in #11823. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by bgamari): See Phab:D2230 for a quick patch to catch this sort of issue during C-- pretty-printing. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"f091218ae14a24f9dbd991794c2da6377364578b/ghc" f091218/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="f091218ae14a24f9dbd991794c2da6377364578b" CLabel: Catch #11155 during C-- pretty-printing In #11555 we ended up generating references to the non-existence stg_ap_0_upd. Here we add asserts to verify that we don't generate references to non-existent selector or application symbols. It would likely also make sense to add further asserts during code generation, so we can catch the issue even closer to its source. Test Plan: Validate Reviewers: simonmar, austin, ezyang Reviewed By: simonmar, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2230 GHC Trac Issues: #11155 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:16> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11155: Trivial thunk gives "undefined reference to stg_ap_0_upd_info" -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | simplCore/should_compile/T11155 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Simon Peyton Jones <simonpj@…>): In [changeset:"2dbf88b3558c3b53a1207fb504232c3da67b266e/ghc" 2dbf88b3/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2dbf88b3558c3b53a1207fb504232c3da67b266e" Fix get getIdFromTrivialExpr This bug, discovered by Trac #15325, has been lurking since commit 1c9fd3f1c5522372fcaf250c805b959e8090a62c Author: Simon Peyton Jones <simonpj@microsoft.com> Date: Thu Dec 3 12:57:54 2015 +0000 Case-of-empty-alts is trivial (Trac #11155) I'd forgotttnen to modify getIdFromTrivialExpr when I modified exprIsTrivial. Easy to fix, though. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11155#comment:17> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC