From 12b0bb6f15caa5b4b01d0330a7a8d23e3c10842c Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 14 Sep 2015 13:37:38 +0100 Subject: [PATCH] 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 --- rts/Threads.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rts/Threads.c b/rts/Threads.c index 434e1298c2..203a248794 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); -- GitLab