From owner-freebsd-current@FreeBSD.ORG Tue Sep 16 08:13:34 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8835566E for ; Tue, 16 Sep 2014 08:13:34 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2AF77754 for ; Tue, 16 Sep 2014 08:13:33 +0000 (UTC) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s8G8DPY0038549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 16 Sep 2014 11:13:25 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s8G8DPY0038549 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s8G8DOcN038548; Tue, 16 Sep 2014 11:13:24 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 16 Sep 2014 11:13:24 +0300 From: Konstantin Belousov To: "Justin T. Gibbs" Subject: Re: libthr and main thread stack size Message-ID: <20140916081324.GQ2737@kib.kiev.ua> References: <53E36E84.4060806@ivan-labs.com> <20140808052807.GB93733@kib.kiev.ua> <53E48B38.9010607@ivan-labs.com> <20140808112201.GC93733@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="byChrBWZKGwyiGYd" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: "Ivan A. Kosarev" , freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Sep 2014 08:13:34 -0000 --byChrBWZKGwyiGYd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 15, 2014 at 03:47:41PM -0600, Justin T. Gibbs wrote: > On Aug 8, 2014, at 5:22 AM, Konstantin Belousov wro= te: >=20 > ? >=20 > > Below is the patch which adds environment variable > > LIBPTHREAD_BIGSTACK_MAIN. Setting it to any value results in the > > main thread stack left as is, and other threads allocate stack > > below the area of RLIMIT_STACK. Try it. I do not want to set this > > behaviour as default. > > Is there a reason this should not be the default? Looking at the > getrlimit() page on the OpenGroup?s site they say: > > RLIMIT_STACK This is the maximum size of the initial thread's stack, > in bytes. The implementation does not automatically grow the stack > beyond this limit. If this limit is exceeded, SIGSEGV shall be > generated for the thread. If the thread is blocking SIGSEGV, or the > process is ignoring or catching SIGSEGV and has not made arrangements > to use an alternate stack, the disposition of SIGSEGV shall be set to > SIG_DFL before it is generated. > > Does posix say something different? > > I ran into this issue when debugging a segfault on Postgres when > running an (arguably quite bogus) query that should have fit within > both the configured stack rlimit and Postgres? configured stack limit. > The Postgres backend is really just single threaded, but happens > to pull in libpthread due to the threading support in some of the > libraries it uses. The segfault definitely violates POLA. > > ? Justin I am conservative to not disturb the address space layout in single go. If enough people test this setting, I can consider flipping the default to the reverse. I am still curious why the things were done in this way, but nobody replied. --byChrBWZKGwyiGYd Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJUF/EjAAoJEJDCuSvBvK1BNYwP/AiJi6bhBH/vZ+cvfiYY/FgZ zAKdMk8vTpdwTWImNwDoRocs5GeEd4TrplqFf9m74LvYzM22G/2/kHsoq0PytL32 rf0GJ1s8bA2hoVK81k0KTK1hUOylvxZK2UtS8glFnNBUQh1MAk//2cdy8QMBNFiH jnByR7zZ3opKbuNo3+ii2uFuqDZZyU+mjUqIhcDPqLCHCjBXj3jpoIgtn6XpLISA J83kIFeeXX+VWufw084mIlomu+Q4m45KDOdKIwTPXSsBTuKJcBfSo7g46NQRvbL4 dyUAKfrbq7mvaftKi8hOYvwYG88CX5fn7RwRoyXBUSMVDvo/tbvl8faWTKym4NC/ 5g2ZJ3uqaCU9eJU/+nMglAYryhpjJXiDBK9wpfEuc9luXJ1oIRCPsMADjFgbgcBR TujOabues6eLDS62BdohLK0tb7eDfjdHxz8b+TILOt9KmWIklkCSktDL8vWO2Z2B 2lvgJcieHLCj/RwMAwTPibUhqtclI77W/ET48s2kl7Lw9zHU40O5SnZzjih+jE1o Sq5B3/1bb/Wqu2WrF4R/Wta3msV2UAU2OEe8wJMf3YUCJyxFfU2IchFB+AwD1224 jjdOGdJ+EIaCXW0Z1LJO42l5elSlnOyCAcbdOyVEpVjXLTF2DlHedlORd/sb/GZN 8raPLokhNq0F7Ulue6ay =0Iaa -----END PGP SIGNATURE----- --byChrBWZKGwyiGYd--