On Tue, 23 Feb 2016 15:41:23 +0100
Marc Vertes <marc.vertes_at_ugrid.net> wrote:
> It doesn't work. And on my side, I tried a similar modification
> (using getrlimit) in
> src/third_party/mozjs-38/extract/js/src/jsnativestack.cpp without
> But I found a separate patch which works:
> --- src/mongo/scripting/mozjs/implscope.cpp.orig
> +++ src/mongo/scripting/mozjs/implscope.cpp
> _at_@ -258,6 +258,7 @@
> // TODO: What if we are running on a platform with very
> // large pages, like 4MB?
> + //JS_SetNativeStackQuota(_runtime, available.get() - (64
> * 1024)); JS_SetNativeStackQuota(_runtime, available.get() - (32 *
> 1024)); }
> So I believe that it should be a matter of increasing allocated stack
> at thread creation. I'm still not able to do that, despite my various
The main thread's stack is allocated by kernel. In practice, kernel
maps the stack on virtual address space so that it's size is the
stack rlimit, but it only allocates the first pages of it. When the
stack is needed more, the kernel automatically commits/allocates more
of the stack.
Musl returns you the actual size of the stack in use. Glibc returns you
the maximum stack size (but kernel might fail to allocate it).
Another attempt would be to patch that function to have in the
beginning a call to function that has large stack array and that writes
static void commit_stack(void)
foo = foo[sizeof(foo)-1] = 0;
Assuming gcc will not optimize it away.
After this kernel should commit the memory, and musl's
pthread_getattr_np should return value reflecting that.
Received on Tue Feb 23 2016 - 17:04:46 UTC