[commit: ghc] master: Account for stack allocation in the thread's allocation counter (12b0bb6)

git at git.haskell.org git at git.haskell.org
Mon Sep 14 14:08:18 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/12b0bb6f15caa5b4b01d0330a7a8d23e3c10842c/ghc

>---------------------------------------------------------------

commit 12b0bb6f15caa5b4b01d0330a7a8d23e3c10842c
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Mon Sep 14 13:37:38 2015 +0100

    Account for stack allocation in the thread's allocation counter
    
    Summary: (see comment for details)
    
    Test Plan: validate
    
    Reviewers: bgamari, ezyang, austin
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D1243


>---------------------------------------------------------------

12b0bb6f15caa5b4b01d0330a7a8d23e3c10842c
 rts/Threads.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/rts/Threads.c b/rts/Threads.c
index 434e129..203a248 100644
--- a/rts/Threads.c
+++ b/rts/Threads.c
@@ -602,7 +602,15 @@ threadStackOverflow (Capability *cap, StgTSO *tso)
                   "allocating new stack chunk of size %d bytes",
                   chunk_size * sizeof(W_));
 
+    // Charge the current thread for allocating stack.  Stack usage is
+    // non-deterministic, because the chunk boundaries might vary from
+    // run to run, but accounting for this is better than not
+    // accounting for it, since a deep recursion will otherwise not be
+    // subject to allocation limits.
+    cap->r.rCurrentTSO = tso;
     new_stack = (StgStack*) allocate(cap, chunk_size);
+    cap->r.rCurrentTSO = NULL;
+
     SET_HDR(new_stack, &stg_STACK_info, old_stack->header.prof.ccs);
     TICK_ALLOC_STACK(chunk_size);
 



More information about the ghc-commits mailing list