X-Original-To: alpine-aports@mail.alpinelinux.org Delivered-To: alpine-aports@mail.alpinelinux.org Received: from mail.alpinelinux.org (dallas-a1.alpinelinux.org [127.0.0.1]) by mail.alpinelinux.org (Postfix) with ESMTP id 34956DCB75A for ; Tue, 23 Feb 2016 16:20:18 +0000 (UTC) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 94D04DC03EA for ; Tue, 23 Feb 2016 16:20:16 +0000 (UTC) Received: by mail-lb0-f180.google.com with SMTP id x4so104681670lbm.0 for ; Tue, 23 Feb 2016 08:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Rab+rs8XGvf4cpMkjpuyO5tYE2IcWtHND3WGz0SSlmI=; b=Huk9qcRt//g5Tv/TTLYeHXrzcb6H1vkYD77JCW3mKMbEPL+mxok3uK018qzvIpQ34G P4gGUIJ8oBcRqfDvm3QJfMmK1b0OvHTUnJO7g7PzRpldKe2GtOhH676FdO2p5eVJGs1b Lu+XKUhGDgLt/iVQSiVDgbYRtu5oED5hQ08weLJB2RXyThTij3PMJ0DG4sUiqkCVlYAE //K/oFMqugJXP9mek+a7tnm4nmH4Zivbs+l/Bqizbgb88ec7e5THIcLLnBikEcOVoKe9 oQI2cTITsyQwU75o2aa3Pl+i075uOhd+7aXQTi3eTdmXzPpEPxncJxQ8Hh73bkVuj3Y5 tQ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; bh=Rab+rs8XGvf4cpMkjpuyO5tYE2IcWtHND3WGz0SSlmI=; b=f3LE6cODNhBjUImePpeDoNfCLQ+1yquISu1QOJ3jPFSJaZ2g7VOm2OpD8WPZuxgkoi Dyh5LNfML+ctB1j579qQJdS5OofnYV5RQUrdvddA5vszxsk9RkXqkg4zrQOqZy3tuJRx NN+ZozdDD+wewbeSjCBzvoEkHJXclfg/CwiKfBLABF7SkGis84VhfQFgkz+cAyp3Jini 8DLy5imH8iHhAtepN4tY///U/3o6mbxxEVSSBlV4jO1+SNuIpglvPNCrLyfenaatNFaf R2O6DdOTN1JYAGqIxW5TzE9HFvBOUNRmRSJ545Ko9+2V+4LzD/9Z8isfNHyTvwr7yd7D qg1A== X-Gm-Message-State: AG10YOTcD8hNJv74cwedKhK66ZebdMGSdBqPMdDHYKm2AAzwV2l0jvAq7YQilRiaEr8LZg== X-Received: by 10.112.209.99 with SMTP id ml3mr12164729lbc.26.1456244413848; Tue, 23 Feb 2016 08:20:13 -0800 (PST) Received: from vostro ([83.145.235.201]) by smtp.gmail.com with ESMTPSA id i1sm4175502lbs.38.2016.02.23.08.20.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Feb 2016 08:20:13 -0800 (PST) Sender: =?UTF-8?Q?Timo_Ter=C3=A4s?= Date: Tue, 23 Feb 2016 18:20:10 +0200 From: Timo Teras To: Marc Vertes Cc: alpine-aports@lists.alpinelinux.org Subject: Re: [alpine-aports] [PATCH] testing/mongodb: fix bug #5117 where mongo fails at start Message-ID: <20160223182010.039b4469@vostro> In-Reply-To: <339A4F58-917F-455E-9B0E-E1E5A5902ADE@ugrid.net> References: <1456083383-9196-1-git-send-email-marc.vertes@ugrid.net> <20160223150743.33e55efa@vostro.util.wtbts.net> <9D775D86-8A4D-49ED-8512-EBD572ECF6D6@ugrid.net> <20160223170446.483be803@vostro.util.wtbts.net> <20160223175029.23bcadb2@vostro> <339A4F58-917F-455E-9B0E-E1E5A5902ADE@ugrid.net> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.28; x86_64-alpine-linux-musl) X-Mailinglist: alpine-aports Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 23 Feb 2016 17:10:44 +0100 Marc Vertes wrote: > > Le 23 f=C3=A9vr. 2016 =C3=A0 16:50, Timo Teras a = =C3=A9crit : > >=20 > > On Tue, 23 Feb 2016 16:35:58 +0100 > > Marc Vertes wrote: > > =20 > >> 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). > >>=20 > >> Changing size does nothing. > >>=20 > >> I also noticed that pthread_getattr_np and pthread_attr_getstack > >> where not performed from the main thread (gettid !=3D getpid) =20 > >=20 > > Right. ulimit should be used only for main thread. Not the created > > threads with libc allocated stack. That needs a fix. > >=20 > > pthread_attr_getstack should return the lowest addressable byte of > > the stack. So indeed, if we change the size, we need to adjust base > > accordingly on system with downward growing stack. Something like: > >=20 > > --- > > mongodb-src-r3.2.1.orig/src/mongo/platform/stack_locator_pthread_getatt= r_np.cpp > > +++ > > mongodb-src-r3.2.1/src/mongo/platform/stack_locator_pthread_getattr_np.= cpp > > @@ -31,6 +31,7 @@ #include "mongo/platform/stack_locator.h" > >=20 > > #include > > +#include > >=20 > > #include "mongo/util/assert_util.h" > > #include "mongo/util/scopeguard.h" > > @@ -52,6 +53,13 @@ > > invariant(result =3D=3D 0); > > invariant(base !=3D nullptr); > > invariant(size !=3D 0); > > + > > + struct rlimit rl; > > + > > + base +=3D size; > > + invariant(getrlimit(RLIMIT_STACK, &rl) =3D=3D 0); > > + size =3D rl.rlim_cur ? : 2 * 1024 * 1024; > > + base -=3D size; > >=20 > > // TODO: Assumes a downward growing stack. Note here that > > // getstack returns the stack *base*, being the bottom of the > > =20 >=20 > This one works! > But I'm afraid of possible stack overlap between threads if it is run > not from main thread. Is it your concern too ? For non-main threads we should not use rlimit. the rlimit stuff should be in if (something) so that it is triggered for main thread only. For main thread the ulimit should be safe. Kernel should create mappings in such a way that they don't overlap. In fact, glibc uses getrlimit(RLIMIT_STACK) inside pthread_getattr_np call to calculate base exactly this way. /Timo --- Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org Help: alpine-aports+help@lists.alpinelinux.org ---