Mail archive
alpine-aports

Re: [alpine-aports] [PATCH] testing/mongodb: fix for #5117

From: Timo Teras <timo.teras_at_iki.fi>
Date: Tue, 23 Feb 2016 19:16:12 +0200

On Tue, 23 Feb 2016 17:11:09 +0000
Marc Vertes <marc.vertes_at_ugrid.net> wrote:

> mongodb-src-r3.2.1.orig/src/mongo/platform/stack_locator_pthread_getattr_np.cpp
> -+++
> mongodb-src-r3.2.1/src/mongo/platform/stack_locator_pthread_getattr_np.cpp
> -_at_@ -31,6 +31,7 @@
> - #include "mongo/platform/stack_locator.h"
> +--- a/src/mongo/platform/stack_locator_pthread_getattr_np.cpp
> ++++ b/src/mongo/platform/stack_locator_pthread_getattr_np.cpp
> +_at_@ -32,6 +32,12 @@
>
> #include <pthread.h>
> -+#include <sys/resource.h>
>
> ++#if defined(__linux__) && !defined(__GLIBC__) /* Assume Musl libc */
> ++#include <sys/resource.h>
> ++#include <sys/syscall.h>
> ++#include <unistd.h>
> ++#endif
> ++
> #include "mongo/util/assert_util.h"
> #include "mongo/util/scopeguard.h"
> -_at_@ -52,6 +53,11 @@
> - invariant(result == 0);
> - invariant(base != nullptr);
> - invariant(size != 0);
> -+
> -+ struct rlimit rl;
> +
> +_at_@ -48,6 +54,16 @@
> + size_t size = 0;
> +
> + auto result = pthread_attr_getstack(&selfAttrs, &base, &size);
> +
> -+ invariant(getrlimit(RLIMIT_STACK, &rl) == 0);
> ++#if defined(__linux__) && !defined(__GLIBC__) /* Assume Musl libc */
> ++ struct rlimit rl = { 0 };
> ++ base += size;
> ++ if (syscall(SYS_gettid) == getpid()) { /* In the
> main thread */ ++ invariant(getrlimit(RLIMIT_STACK,
> &rl) == 0); ++ }
> + size = rl.rlim_cur ? : 2 * 1024 * 1024;
> ++ base -= size;
> ++#endif

Technically the getrlimit() is perfectly ok to do on all platforms. But
we know glibc returns rlimit anway, so it can be skipped there.

I would have put all of the base/size twiddling inside the if(). Then
struct rlimit does not need initialization either. But thats a minor
thingy. You care to fix that, or should I just apply this?


>
> - // TODO: Assumes a downward growing stack. Note here that
> - // getstack returns the stack *base*, being the bottom of the
> + invariant(result == 0);
> + invariant(base != nullptr);



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