Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
88dba610
Commit
88dba610
authored
Sep 08, 2013
by
thoughtpolice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Default to infinite stack size (#8189)"
This reverts commit
d85044f6
.
parent
c798a8c6
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
73 deletions
+33
-73
docs/users_guide/runtime_control.xml
docs/users_guide/runtime_control.xml
+4
-7
includes/Rts.h
includes/Rts.h
+1
-2
includes/rts/Constants.h
includes/rts/Constants.h
+1
-1
includes/rts/storage/GC.h
includes/rts/storage/GC.h
+3
-10
rts/RtsFlags.c
rts/RtsFlags.c
+2
-2
rts/RtsUtils.c
rts/RtsUtils.c
+3
-3
rts/Schedule.c
rts/Schedule.c
+1
-1
rts/Threads.c
rts/Threads.c
+2
-8
rts/sm/Storage.c
rts/sm/Storage.c
+16
-39
No files found.
docs/users_guide/runtime_control.xml
View file @
88dba610
...
...
@@ -676,13 +676,10 @@ $ ./prog -f +RTS -H32m -S -RTS -h foo bar
<indexterm><primary>
stack, maximum size
</primary></indexterm>
</term>
<listitem>
<para>
[
Default: infinite
]
Set the maximum stack
size for an individual thread to
<replaceable>
size
</replaceable>
bytes. A setting of zero
implies no maximum stack size limit. If the thread
attempts to exceed this limit, it will be sent the
<literal>
StackOverflow
</literal>
exception.
<para>
[
Default: 8M
]
Set the maximum stack size for
an individual thread to
<replaceable>
size
</replaceable>
bytes. If the thread attempts to exceed this limit, it will
be send the
<literal>
StackOverflow
</literal>
exception.
</para>
<para>
This option is there mainly to stop the program eating up
...
...
includes/Rts.h
View file @
88dba610
...
...
@@ -250,7 +250,7 @@ void getWin32ProgArgv(int *argc, wchar_t **argv[]);
void
setWin32ProgArgv
(
int
argc
,
wchar_t
*
argv
[]);
#endif
void
stackOverflow
(
StgTSO
*
tso
);
void
stackOverflow
(
void
);
void
stg_exit
(
int
n
)
GNU_ATTRIBUTE
(
__noreturn__
);
...
...
@@ -268,7 +268,6 @@ int stg_sig_install (int, int, void *);
#define EXIT_INTERRUPTED 252
#define EXIT_HEAPOVERFLOW 251
#define EXIT_KILLED 250
#define EXIT_STACKOVERFLOW 249
/* -----------------------------------------------------------------------------
Miscellaneous garbage
...
...
includes/rts/Constants.h
View file @
88dba610
...
...
@@ -234,7 +234,7 @@
* stopped for one reason or another. See typedef StgThreadReturnCode
* in TSO.h.
*/
#define HeapOverflow 1
#define HeapOverflow 1
/* might also be StackOverflow */
#define StackOverflow 2
#define ThreadYielding 3
#define ThreadBlocked 4
...
...
includes/rts/storage/GC.h
View file @
88dba610
...
...
@@ -132,13 +132,7 @@ extern generation * oldest_gen;
Allocates memory from the nursery in
the current Capability. This can be
done without taking a global lock,
unlike allocate(). In the event of a
heap overflow the program will be
terminated.
StgPtr allocateFail(Capability *cap, W_ n)
Similar to allocate() but returns NULL
in the event of a heap overflow.
unlike allocate().
StgPtr allocatePinned(Capability *cap, W_ n)
Allocates a chunk of contiguous store
...
...
@@ -160,7 +154,6 @@ extern generation * oldest_gen;
-------------------------------------------------------------------------- */
StgPtr
allocate
(
Capability
*
cap
,
W_
n
);
StgPtr
allocateFail
(
Capability
*
cap
,
W_
n
);
StgPtr
allocatePinned
(
Capability
*
cap
,
W_
n
);
/* memory allocator for executable memory */
...
...
rts/RtsFlags.c
View file @
88dba610
...
...
@@ -94,7 +94,7 @@ void initRtsFlagsDefaults(void)
RtsFlags
.
GcFlags
.
statsFile
=
NULL
;
RtsFlags
.
GcFlags
.
giveStats
=
NO_GC_STATS
;
RtsFlags
.
GcFlags
.
maxStkSize
=
0
;
/* off by default */
RtsFlags
.
GcFlags
.
maxStkSize
=
(
8
*
1024
*
1024
)
/
sizeof
(
W_
);
RtsFlags
.
GcFlags
.
initialStkSize
=
1024
/
sizeof
(
W_
);
RtsFlags
.
GcFlags
.
stkChunkSize
=
(
32
*
1024
)
/
sizeof
(
W_
);
RtsFlags
.
GcFlags
.
stkChunkBufferSize
=
(
1
*
1024
)
/
sizeof
(
W_
);
...
...
@@ -233,7 +233,7 @@ usage_text[] = {
" -? Prints this message and exits; the program is not executed"
,
" --info Print information about the RTS used by this program"
,
""
,
" -K<size> Sets the maximum stack size (default
s to infinite
) Egs: -K32k -K512k"
,
" -K<size> Sets the maximum stack size (default
8M
) Egs: -K32k -K512k"
,
" -ki<size> Sets the initial thread stack size (default 1k) Egs: -ki4k -ki2m"
,
" -kc<size> Sets the stack chunk size (default 32k)"
,
" -kb<size> Sets the stack chunk buffer size (default 1k)"
,
...
...
rts/RtsUtils.c
View file @
88dba610
...
...
@@ -114,9 +114,9 @@ stgFree(void* p)
-------------------------------------------------------------------------- */
void
stackOverflow
(
StgTSO
*
tso
)
stackOverflow
(
void
)
{
StackOverflowHook
(
tso
->
tot_stack_s
ize
*
sizeof
(
W_
));
StackOverflowHook
(
RtsFlags
.
GcFlags
.
maxStkS
ize
*
sizeof
(
W_
));
#if defined(TICKY_TICKY)
if
(
RtsFlags
.
TickyFlags
.
showTickyStats
)
PrintTickyInfo
();
...
...
rts/Schedule.c
View file @
88dba610
...
...
@@ -393,7 +393,7 @@ schedule (Capability *initialCapability, Task *task)
run_thread:
// CurrentTSO is the thread to run.
I
t might be different if we
// CurrentTSO is the thread to run.
t might be different if we
// loop back to run_thread, so make sure to set CurrentTSO after
// that.
cap
->
r
.
rCurrentTSO
=
t
;
...
...
rts/Threads.c
View file @
88dba610
...
...
@@ -499,8 +499,7 @@ threadStackOverflow (Capability *cap, StgTSO *tso)
IF_DEBUG
(
sanity
,
checkTSO
(
tso
));
if
(
(
RtsFlags
.
GcFlags
.
maxStkSize
>
0
)
// don't throw if we have infinite stack
&&
(
tso
->
tot_stack_size
>=
RtsFlags
.
GcFlags
.
maxStkSize
)
if
(
tso
->
tot_stack_size
>=
RtsFlags
.
GcFlags
.
maxStkSize
&&
!
(
tso
->
flags
&
TSO_BLOCKEX
))
{
// NB. never raise a StackOverflow exception if the thread is
// inside Control.Exceptino.block. It is impractical to protect
...
...
@@ -576,12 +575,7 @@ threadStackOverflow (Capability *cap, StgTSO *tso)
"allocating new stack chunk of size %d bytes"
,
chunk_size
*
sizeof
(
W_
));
new_stack
=
(
StgStack
*
)
allocateFail
(
cap
,
chunk_size
);
if
(
new_stack
==
NULL
)
{
// We've really run out of memory in the heap, so die.
stackOverflow
(
tso
);
stg_exit
(
EXIT_STACKOVERFLOW
);
}
new_stack
=
(
StgStack
*
)
allocate
(
cap
,
chunk_size
);
SET_HDR
(
new_stack
,
&
stg_STACK_info
,
old_stack
->
header
.
prof
.
ccs
);
TICK_ALLOC_STACK
(
chunk_size
);
...
...
rts/sm/Storage.c
View file @
88dba610
...
...
@@ -624,20 +624,20 @@ move_STACK (StgStack *src, StgStack *dest)
}
/* -----------------------------------------------------------------------------
allocate
Fail
()
allocate()
This allocates memory in the current thread - it is intended for
use primarily from STG-land where we have a Capability.
use primarily from STG-land where we have a Capability. It is
better than allocate() because it doesn't require taking the
sm_mutex lock in the common case.
Memory is allocated directly from the nursery if possible (but not
from the current nursery block, so as not to interfere with
Hp/HpLim).
We return NULL in the event of a heap overflow.
-------------------------------------------------------------------------- */
StgPtr
allocate
Fail
(
Capability
*
cap
,
W_
n
)
allocate
(
Capability
*
cap
,
W_
n
)
{
bdescr
*
bd
;
StgPtr
p
;
...
...
@@ -655,7 +655,14 @@ allocateFail (Capability *cap, W_ n)
req_blocks
>=
HS_INT32_MAX
)
// avoid overflow when
// calling allocGroup() below
{
return
NULL
;
// heap overflow
heapOverflow
();
// heapOverflow() doesn't exit (see #2592), but we aren't
// in a position to do a clean shutdown here: we
// either have to allocate the memory or exit now.
// Allocating the memory would be bad, because the user
// has requested that we not exceed maxHeapSize, so we
// just exit.
stg_exit
(
EXIT_HEAPOVERFLOW
);
}
ACQUIRE_SM_LOCK
...
...
@@ -713,36 +720,6 @@ allocateFail (Capability *cap, W_ n)
return
p
;
}
/* -----------------------------------------------------------------------------
allocate()
This allocates memory in the current thread - it is intended for
use primarily from STG-land where we have a Capability.
Memory is allocated directly from the nursery if possible (but not
from the current nursery block, so as not to interfere with
Hp/HpLim).
We crash with a HeapOverflow when the allocation fails.
-------------------------------------------------------------------------- */
StgPtr
allocate
(
Capability
*
cap
,
W_
n
)
{
StgPtr
p
=
allocateFail
(
cap
,
n
);
if
(
p
==
NULL
)
{
heapOverflow
();
// heapOverflow() doesn't exit (see #2592), but we aren't
// in a position to do a clean shutdown here: we
// either have to allocate the memory or exit now.
// Allocating the memory would be bad, because the user
// has requested that we not exceed maxHeapSize, so we
// just exit.
stg_exit
(
EXIT_HEAPOVERFLOW
);
}
return
p
;
}
/* ---------------------------------------------------------------------------
Allocate a fixed/pinned object.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment