Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit a1a5ad8

Browse files
committed
fix issue 18547 - Win32: throwing exception in fiber crashes application
increase the default stack size because exception handling might need up to 16k. The actually used stack can depend on the version of DbgHelp.dll, the existence of debug information and possibly other conditions.
1 parent 3db3820 commit a1a5ad8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/core/thread.d

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4071,6 +4071,14 @@ class Fiber
40714071
// Initialization
40724072
///////////////////////////////////////////////////////////////////////////
40734073

4074+
version(Windows)
4075+
// exception handling walks the stack, invoking DbgHelp.dll which
4076+
// needs up to 16k of stack space depending on the version of DbgHelp.dll,
4077+
// the existence of debug symbols and other conditions. Avoid causing
4078+
// stack overflows by defaulting to a larger stack size
4079+
enum defaultStackPages = 8;
4080+
else
4081+
enum defaultStackPages = 4;
40744082

40754083
/**
40764084
* Initializes a fiber object which is associated with a static
@@ -4087,7 +4095,7 @@ class Fiber
40874095
* In:
40884096
* fn must not be null.
40894097
*/
4090-
this( void function() fn, size_t sz = PAGESIZE*4,
4098+
this( void function() fn, size_t sz = PAGESIZE * defaultStackPages,
40914099
size_t guardPageSize = PAGESIZE ) nothrow
40924100
in
40934101
{
@@ -4115,15 +4123,15 @@ class Fiber
41154123
* In:
41164124
* dg must not be null.
41174125
*/
4118-
this( void delegate() dg, size_t sz = PAGESIZE*4,
4126+
this( void delegate() dg, size_t sz = PAGESIZE * defaultStackPages,
41194127
size_t guardPageSize = PAGESIZE ) nothrow
41204128
in
41214129
{
41224130
assert( dg );
41234131
}
41244132
do
41254133
{
4126-
allocStack( sz, guardPageSize);
4134+
allocStack( sz, guardPageSize );
41274135
reset( dg );
41284136
}
41294137

0 commit comments

Comments
 (0)