Mail archive
alpine-aports

Re: [alpine-aports] [PATCH] testing/mongodb: fix bug #5117 where mongo fails at start

From: Marc Vertes <marc.vertes_at_ugrid.net>
Date: Tue, 23 Feb 2016 16:35:58 +0100

> Le 23 févr. 2016 à 16:04, Timo Teras <timo.teras_at_iki.fi> a écrit :
>
> 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
>> success.
>>
>> 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
>> attempts.
>
> 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
> to it.
>
> Something like:
>
> static void commit_stack(void)
> {
> char foo[1024*1024*2];
> foo[0] = 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.

No success. I think that the base address returned by pthread_attr_getstack(&attr, &base, &size)
is the problem. Increasing the size (like with getrlimit) doesn't change the test in StackLocator.available() which triggers abort:
it checks the available space against this base address (&localaddr - base > quota).

Changing size does nothing.

I also noticed that pthread_getattr_np and pthread_attr_getstack where not performed from the main thread (gettid != getpid)

Marc

---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Tue Feb 23 2016 - 16:35:58 GMT