From owner-freebsd-current@freebsd.org Thu Jan 21 16:02:50 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 31605A8B46A for ; Thu, 21 Jan 2016 16:02:50 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: from mail-io0-x236.google.com (mail-io0-x236.google.com [IPv6:2607:f8b0:4001:c06::236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F182E134C; Thu, 21 Jan 2016 16:02:49 +0000 (UTC) (envelope-from carpeddiem@gmail.com) Received: by mail-io0-x236.google.com with SMTP id 77so58559551ioc.2; Thu, 21 Jan 2016 08:02:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=doc20XLQdzngXkRzCi4LWZ4WU7Y3HOH5qz4BlqK3vLs=; b=id/4iP50bRFjRQr1D105gr1U9XIA4WK9npVmm6N7coTbmGQR3LzeNYVUsulgULzL4s 6bY7bsojGmsKNsLsEJcYcUFF7kMPuAMiT35dtXJtn+1NAEa1aCxueKBTnvAlns/PJdea 9+XGuqNnECOY9fTppVE5TlShZDhrk6pF0SS0ZjwSoI4GPKFlec8qbEV3zaK4yGaSjSI2 RYbdhbQta9DTiCapVRUwz25T2XuaQdYuQQZLIg8VGJvcyJ69PjSmFxFrI9O/p7qINaVB 6p2NpqgxPC6zryqUAA1TFIG+t3grV3/idPiQyRy+rZTT0d5ACF1GoS8XCdKC7RqeCkCi lLlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=doc20XLQdzngXkRzCi4LWZ4WU7Y3HOH5qz4BlqK3vLs=; b=QRyui1FZY+ZTTmjiIRS0tcWWyvf/kVpv16WCv7hIorPXn4SndBYqOhbZEG6r5Ttx24 fe+O98CZzm/OT1X3j/gXrT5JPdtHbtq1orGgtvmCafC5EpSfsMMoxlBDykbmLbJB8Qek U/QPkFx0Ufi073HWJdcz4FLmrU4OzCOpAKKnDmrVbhnR6nhIOWOUSGQOngfdglMPQ1MT vQI/HTZu5O9j2KsrjTqxQB38nlhMqKI+vcK4bvpVb3Je5j1h5Ixr3wrUzEbxl1aPyCRo 3HXtgD4UGGIUsV3EZKy3Q7gzUyZB0nQy/yLdwnkiHV5PDCeMnQyJPZEtfFvrVwTueHKl P7ZQ== X-Gm-Message-State: AG10YOQbSEhAlPp3vV6/ukY6HHqIA9pAdz3WHgQiXwnm5z6Qc+DkpOaXoOgbcL6oeizz+Y4+a29e/LZPdWZ+9w== X-Received: by 10.107.62.5 with SMTP id l5mr14092075ioa.180.1453392169482; Thu, 21 Jan 2016 08:02:49 -0800 (PST) MIME-Version: 1.0 Sender: carpeddiem@gmail.com Received: by 10.107.39.66 with HTTP; Thu, 21 Jan 2016 08:02:29 -0800 (PST) In-Reply-To: <913B1E7A-5192-430F-ABAF-576DFCFF98E6@FreeBSD.org> References: <531F42CD.8020307@citrix.com> <913B1E7A-5192-430F-ABAF-576DFCFF98E6@FreeBSD.org> From: Ed Maste Date: Thu, 21 Jan 2016 11:02:30 -0500 X-Google-Sender-Auth: N-0cbH7xbDxaFyCJtmtHtm9ALEI Message-ID: Subject: Re: Too low PTHREAD_STACK_MIN value? To: David Chisnall Cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , FreeBSD Current Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 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: Thu, 21 Jan 2016 16:02:50 -0000 On 11 March 2014 at 20:38, David Chisnall wrote: > On 12 Mar 2014, at 02:07, Roger Pau Monn=C3=A9 wro= te: > >> I've found out that the value PTHREAD_STACK_MIN is currently set (2048 >> bytes) seems to be way too low > > This looks like an error in your code. The spec says: > >> PTHREAD_STACK_MIN >> Minimum size in bytes of thread stack storage. >> Minimum Acceptable Value: 0 > > It is meant to be the minimum value that the system can give for a thread= stack. The purpose of this constant is for languages that do their own st= ack management bit some chain of activation records of segmented stacks, bu= t want to use pthreads for threading, so that they can allocate the smalles= t possible stack that allows pthread cleanup to work. > > Using it from C code is very likely to be a mistake. I found that lang/polyml uses PTHREAD_STACK_MIN for a trivial signal handler thread it creates[1]. They found it was too small and implemented a 4K minimum bound to fix polyml on FreeBSD[2]. Even if this isn't really the intended use of PTHREAD_STACK_MIN it suggests the 2K x86 minimum may indeed be too low. I ran into this while trying LLVM's libunwind, which requires more stack space. 2K is certainly too low with LLVM libunwind. Is it reasonable to just increase it to say 8K? [1] https://github.com/polyml/polyml/blob/6c8add163fc39271da1056e43387a3d33= ebd62c6/libpolyml/sighandler.cpp#L527 [2] https://github.com/polyml/polyml/commit/c59360ba74ac99bd9e3d342af214ced= 39cf0568b