[GHC] #8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory ----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: new Priority: highest | Milestone: 7.8.2 Component: Runtime System | Version: 7.8.1-rc2 Keywords: | Operating System: Windows Architecture: x86_64 (amd64) | Type of failure: Runtime crash Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ----------------------------------+---------------------------------- Consider this: {{{ -- t.hs import System.Environment main :: IO () main = do n <- fmap (read . head) getArgs print $ foldr (+) (0::Int) [0 .. n] }}} Compiled with ghc-7.6.3 and ran thus: {{{ ghc -O2 -rtsopts --make -o t.exe t.hs t.exe +RTS -K4G -RTS 250000000 }}} it works fine! But compiled with 7.8rc2 it segfaults when amount of memory allocated crosses 4G mark. I've discovered this trying to use Agda built with ghc-7.8rc2 but quickly understood this is a general problem and extremely nasty one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: new Priority: highest | Milestone: 7.8.2 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Comment (by awson): Initial problem was that darcs Agda 2.3.3 compiled with ghc-7.8rc2 segfaulted checking https://github.com/crypto-agda/crypto- agda/blob/master/Control/Protoco/Reduction.agda right after the amount of allocated memory crossed 4G mark. If I tried to check this file with `+RTS -H4G` option it segfaulted almost immediately. At the same time, the same Agda compiled with ghc-7.6.3 successfully allocated much more than 4G while checking this file. And I've ran it with default stack (no `+RTS -K...` option). So, perhaps, stack size is not essential here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: new Priority: highest | Milestone: 7.8.2 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Comment (by simonmar): Does it work on a non-Windows platform? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: new Priority: highest | Milestone: 7.8.2 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Comment (by hvr): Replying to [comment:2 simonmar]:
Does it work on a non-Windows platform?
seems so; I've tried the example on Linux/x86_64 with GHC 7.8.0.20140228: {{{ $ ghc -O2 -rtsopts --make t.hs [1 of 1] Compiling Main ( t.hs, t.o ) Linking t ... $ ./t +RTS -s -K4G -RTS 257000000 33024500128500000 4,268,393,264 bytes allocated in the heap 172,568 bytes copied during GC 2,146,986,848 bytes maximum residency (12 sample(s)) 21,224 bytes maximum slop 4203 MB total memory in use (65 MB lost due to fragmentation) Tot time (elapsed) Avg pause Max pause Gen 0 8130 colls, 0 par 2.98s 2.98s 0.0004s 0.0004s Gen 1 12 colls, 0 par 1.69s 1.70s 0.1414s 0.7621s INIT time 0.00s ( 0.00s elapsed) MUT time 2.20s ( 2.20s elapsed) GC time 4.67s ( 4.68s elapsed) EXIT time 0.17s ( 0.17s elapsed) Total time 7.04s ( 7.05s elapsed) %GC time 66.3% (66.4% elapsed) Alloc rate 1,936,992,267 bytes per MUT second Productivity 33.7% of total user, 33.7% of total elapsed }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: patch Priority: highest | Milestone: 7.8.2 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Changes (by awson): * status: new => patch Comment: Oh, after another painful bug hunting I've found the [https://github.com/ghc/ghc/commit/36b042fbf60210ab6859d96e5b4b5e121085816d culprit]. `unsigned long` is 32 bit in Windows 64-bit ABI. I've attached the patch forcing block size to be `unsigned long long` on x86_64. Perhaps, it may be narrowed to 64-bit windows only, though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: patch Priority: highest | Milestone: 7.8.1 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Changes (by awson): * milestone: 7.8.2 => 7.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: patch Priority: highest | Milestone: 7.8.1 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Comment (by simonmar): Good catch, I suspected it might have been something to do with that patch. Though I don't like the fix much. Something like this would be better: {{{ #if SIZEOF_LONG == SIZEOF_VOID_P #define UNIT 1UL #elif SIZEOF_LONGLONG == SIZEOF_VOID_P #define UNIT 1ULL #else #error ... #endif }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: simonmar Type: bug | Status: patch Priority: highest | Milestone: 7.8.1 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Comment (by awson): Done. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: thoughtpolice Type: bug | Status: patch Priority: highest | Milestone: 7.8.1 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Changes (by simonmar): * owner: simonmar => thoughtpolice Comment: Looks good! Austin, could you commit + merge? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate
more than 4G of memory
-----------------------------------+----------------------------------
Reporter: awson | Owner: thoughtpolice
Type: bug | Status: patch
Priority: highest | Milestone: 7.8.1
Component: Runtime System | Version: 7.8.1-rc2
Resolution: | Keywords:
Operating System: Windows | Architecture: x86_64 (amd64)
Type of failure: Runtime crash | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets:
-----------------------------------+----------------------------------
Comment (by Austin Seipp

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: thoughtpolice Type: bug | Status: merge Priority: highest | Milestone: 7.8.1 Component: Runtime System | Version: 7.8.1-rc2 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Changes (by thoughtpolice): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8839: 64 bit windows executables compiled with ghc-7.8rc2 segfault when allocate more than 4G of memory -----------------------------------+---------------------------------- Reporter: awson | Owner: thoughtpolice Type: bug | Status: closed Priority: highest | Milestone: 7.8.1 Component: Runtime System | Version: 7.8.1-rc2 Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -----------------------------------+---------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged in 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8839#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC