Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@4c0fcf1480] [MERGE #2990 @obastemur] xp…
Browse files Browse the repository at this point in the history
…lat: protect CC from un-reasonable stack limits

Merge pull request #2990 from obastemur:better_stack
  • Loading branch information
chakrabot authored and kfarnung committed Jun 5, 2017
1 parent 9f03510 commit f61d105
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions deps/chakrashim/core/pal/src/init/pal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ Initialize()
/*Firstly initiate a lastError */
SetLastError(ERROR_GEN_FAILURE);

// prevent un-reasonable stack limits. (otherwise affects mmap calls later)
#if !defined(__IOS__) && !defined(__ANDROID__)
#ifdef _AMD64_
const rlim_t maxStackSize = 8 * 1024 * 1024; // CC Max stack size
#else
const rlim_t maxStackSize = 2 * 1024 * 1024; // CC Max stack size
#endif
struct rlimit rl;
int err = getrlimit(RLIMIT_STACK, &rl);
if (!err)
{
if (rl.rlim_cur > maxStackSize)
{
rl.rlim_cur = maxStackSize;
err = setrlimit(RLIMIT_STACK, &rl);
_ASSERTE(err == 0 && "Well, the environment has a strange stack limit \
and setrlimit call failed to fix that");
}
}
#endif // !__IOS__ && !__ANDROID__
CriticalSectionSubSysInitialize();

if(NULL == init_critsec)
Expand Down

0 comments on commit f61d105

Please sign in to comment.