[GHC] #10445: Wrong stack space size when using -Ksize

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- After compiling the first example in https://wiki.haskell.org/Performance/Accumulating_parameter: {{{ $ cat Test.hs len :: [a] -> Int len [] = 0 len (x:xs) = len xs + 1 main :: IO () main = print $ len [1..1000000] }}} {{{ $ ghc Test.hs -rtsopts }}} and running {{{ ./Test +RTS -K10K }}} GHC 7.6.3 reports {{{ Stack space overflow: current size 10240 bytes. }}} GHC 7.8.4 reports {{{ Stack space overflow: current size 33632 bytes. }}} and GHC 7.10.1 reports {{{ Stack space overflow: current size 99136 bytes. }}} GHC 7.8.3 and 7.10.1 report an incorrect stack space size. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): I have a vague recollection (from the time that the default stack size limit was effectively removed) that GHC 7.6.3 was lying and would display the stack size limit as the current stack size in that error message regardless of the actual current stack size. I don't understand though why you are seeing a stack size that is so much larger than the limit though; and I also notice that even when increasing the stack size limit to much more than the reported stack size (like `-K1M`) the reported stack size does not change (and then the error message becomes rather confusing). So it does seem likely there is some sort of bug here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by archblob): * cc: simonmar (added) Comment: I think you are right about GHC 7.6.3 I can't see from the code how this worked then. I have a patch that validates but I'm not sure if it's the best approach, here it goes: In https://github.com/ghc/ghc/blob/master/rts/Threads.c#L589, it seems that when we allocate a new chunk, the `chunk_size` is always `RtsFlags.GcFlags.stkChunkSize` at a minimum even though alone or together with the old stack size this will be above the limit set by -K, so the fix is that if that limit is set we don't, because we know the max that we are allowed to allocate. Now what I don't know is if we should always allocate a minimum of `stkChunkSize` and why? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D938 -------------------------------------+------------------------------------- Changes (by archblob): * differential: => Phab:D938 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by archblob): * differential: Phab:D938 => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: patch Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D938 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: new => patch * differential: => Phab:D938 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: archblob Type: bug | Status: patch Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D938, | Phab:D961 -------------------------------------+------------------------------------- Changes (by archblob): * owner: => archblob * differential: Phab:D938 => Phab:D938, Phab:D961 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: archblob Type: bug | Status: patch Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D938, | Phab:D961 -------------------------------------+------------------------------------- Comment (by thoughtpolice): In lieu of Phab:D961 getting flagged by Simon, I'm going to move this out of 7.10.2 - archblob, if you fix it up before the end of this week (when I'd like to do the RC), please just remilestone it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: archblob Type: bug | Status: patch Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D938, | Phab:D961 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * milestone: 7.10.2 => 7.12.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize
-------------------------------------+-------------------------------------
Reporter: asr | Owner: archblob
Type: bug | Status: patch
Priority: normal | Milestone: 7.12.1
Component: Compiler | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions: Phab:D938,
| Phab:D961
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: archblob Type: bug | Status: closed Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D938, | Phab:D961 -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed Comment: This seems to have been merged. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D938, Wiki Page: | Phab:D961 -------------------------------------+------------------------------------- Changes (by rwbarton): * owner: archblob => * status: closed => new * resolution: fixed => Comment: As far as I can tell, this was never actually fixed. It is still broken in both 8.0.1 and in HEAD. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D938, Wiki Page: | Phab:D961 -------------------------------------+------------------------------------- Description changed by asr: @@ -37,1 +37,1 @@ - and GHC 7.10.1 reports + GHC 7.10.1 reports @@ -43,1 +43,8 @@ - GHC 7.8.3 and 7.10.1 report an incorrect stack space size. + and GHC 7.10.2, 7.10.3. 8.0.1 and 8.0.2-rc1 report + + {{{ + Stack space overflow: current size 33624 bytes. + }}} + + + GHC >= 7.8.4 report an incorrect stack space size. New description: After compiling the first example in https://wiki.haskell.org/Performance/Accumulating_parameter: {{{ $ cat Test.hs len :: [a] -> Int len [] = 0 len (x:xs) = len xs + 1 main :: IO () main = print $ len [1..1000000] }}} {{{ $ ghc Test.hs -rtsopts }}} and running {{{ ./Test +RTS -K10K }}} GHC 7.6.3 reports {{{ Stack space overflow: current size 10240 bytes. }}} GHC 7.8.4 reports {{{ Stack space overflow: current size 33632 bytes. }}} GHC 7.10.1 reports {{{ Stack space overflow: current size 99136 bytes. }}} and GHC 7.10.2, 7.10.3. 8.0.1 and 8.0.2-rc1 report {{{ Stack space overflow: current size 33624 bytes. }}} GHC >= 7.8.4 report an incorrect stack space size. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.2 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D938, Wiki Page: | Phab:D961 -------------------------------------+------------------------------------- Changes (by Lemming): * milestone: 8.0.1 => 8.6.2 Comment: I just encountered the problem in GHC-8.6.2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10445: Wrong stack space size when using -Ksize -------------------------------------+------------------------------------- Reporter: asr | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Compiler | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D938, Wiki Page: | Phab:D961 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.2 => 8.8.1 Comment: It sounds like this should be reopened in that case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10445#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC