[GHC] #13807: GHC 8.2 nondeterministic with foreign imports
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.1-rc2 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: -------------------------------------+------------------------------------- See the attached Repro.hs. Reproduction steps: {{{ $ rm Repro.{o,hi}; ghc -O -dunique-increment=-1 Repro.hs; md5sum Repro.hi; rm Repro.{o,hi}; ghc -O -dunique-increment=1 Repro.hs; md5sum Repro.hi; [1 of 1] Compiling Repro ( Repro.hs, Repro.o ) 97f005e3959b657bfac761aa3e8a9447 Repro.hi [1 of 1] Compiling Repro ( Repro.hs, Repro.o ) 691f891fb404eb874e8bedd7bda1c8b7 Repro.hi }}} The crucial difference comes from: {{{ 08fffd1551f79b5aca3cafdceaf865b9 mkStringWriter1 :: Int -> State# RealWorld -> (# State# RealWorld, Ptr Int #) {- Arity: 2, HasNoCafRefs, Strictness: <L,U><S,U>, Unfolding: InlineRule (2, True, False) (\ (ds :: Int) (s :: State# RealWorld) -> case makeStablePtr# @ Int ds s of ds1 { (#,#) ipv ipv1 -> case {__pkg_ccall Int# -> StablePtr# Int -> Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)} 1# ipv1 __label "Repro_d105" (function) mkStringWriter2 ipv of wild { (#,#) ds2 ds3 -> (# ds2, Ptr @ Int ds3 #) } }) -} }}} vs {{{ a766a748e60cec63a74534e03db3bf30 mkStringWriter1 :: Int -> State# RealWorld -> (# State# RealWorld, Ptr Int #) {- Arity: 2, HasNoCafRefs, Strictness: <L,U><S,U>, Unfolding: InlineRule (2, True, False) (\ (ds :: Int) (s :: State# RealWorld) -> case makeStablePtr# @ Int ds s of ds1 { (#,#) ipv ipv1 -> case {__pkg_ccall Int# -> StablePtr# Int -> Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)} 1# ipv1 __label "Repro_d5k1wlNFGaX" (function) mkStringWriter2 ipv of wild { (#,#) ds2 ds3 -> (# ds2, Ptr @ Int ds3 #) } }) -} }}} Notice that the labels are different. This doesn't reproduce under GHC 8.0.2, but that may be only because that version doesn't optimize it this way. This is what GHC 8.0.2 produces: {{{ ccf55489bd76322a9404b365b7be7628 mkStringWriter :: Int -> IO (Ptr Int) {- Arity: 2, HasNoCafRefs, Strictness: <L,U><S,U>, Inline: [NEVER] -} }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.1-rc2 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 niteria): * Attachment "Repro.hs" added. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.1-rc2 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 niteria): * owner: (none) => niteria -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.1-rc2 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 niteria): This reproduces on GHC HEAD as well. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.1-rc2 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 niteria): I don't think this is a regression, the code that creates these labels is quite old: https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/deSugar... -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.2.1-rc2 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 Ben Gamari <ben@…>): In [changeset:"dcdc391609d6ff902989d806266855901c051608/ghc" dcdc3916/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="dcdc391609d6ff902989d806266855901c051608" Fix #13807 - foreign import nondeterminism The problem was that the generated label included a freshly assigned Unique value. Test Plan: Added a new test and looked at the generated stub: ``` #include "HsFFI.h" #ifdef __cplusplus extern "C" { #endif extern HsInt zdmainzdAzdAzuzzlzzgzzg(StgStablePtr the_stableptr); extern HsInt zdmainzdAzdAzumkStringWriter(StgStablePtr the_stableptr); #ifdef __cplusplus } #endif ``` ./validate Reviewers: simonmar, austin, bgamari Reviewed By: simonmar Subscribers: rwbarton, thomie GHC Trac Issues: #13807 Differential Revision: https://phabricator.haskell.org/D3633 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: merge Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.2.1-rc2 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 bgamari): * status: new => merge * milestone: => 8.2.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#13807: GHC 8.2 nondeterministic with foreign imports -------------------------------------+------------------------------------- Reporter: niteria | Owner: niteria Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Compiler | Version: 8.2.1-rc2 Resolution: fixed | 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 bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.2` as 40f4efb18c12d42d7ac735224e105bd177fe0e16. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13807#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC