From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3023 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: pthread_getattr_np Date: Sun, 31 Mar 2013 17:00:05 -0400 Message-ID: <20130331210005.GJ20323@brightrain.aerifal.cx> References: <20130331173518.GH30576@port70.net> <20130331180717.GI20323@brightrain.aerifal.cx> <20130331205139.GI30576@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1364763619 5614 80.91.229.3 (31 Mar 2013 21:00:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 31 Mar 2013 21:00:19 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3024-gllmg-musl=m.gmane.org@lists.openwall.com Sun Mar 31 23:00:47 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UMPMo-0001tp-Sp for gllmg-musl@plane.gmane.org; Sun, 31 Mar 2013 23:00:43 +0200 Original-Received: (qmail 11271 invoked by uid 550); 31 Mar 2013 21:00:18 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 10238 invoked from network); 31 Mar 2013 21:00:17 -0000 Content-Disposition: inline In-Reply-To: <20130331205139.GI30576@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:3023 Archived-At: On Sun, Mar 31, 2013 at 10:51:39PM +0200, Szabolcs Nagy wrote: > > In practice, it seems like GC applications only care about the start > > (upper limit) of the stack, not the other end; they use the current > > stack pointer for the other limit. We could probe the current stack > > pointer of the target thread by freezing it (with the synccall magic), > > but this seems like it might be excessively costly for no practical > > benefit... > > eg. address sanitizer creates a shadow map for the stack so > at least it needs a reasonably sized upper bound on the > stack size (but it does the /proc parsing magic itselfs for > the main thread at startup so we don't have to support that) > > if the lowend is not used otherwise then we can give arbitrary > result (eg always returning highend-5MB or using the rlimit > truncated to some value when it's unlimited) > > all the calls to this function seem to use pthread_self() > at thread creation or startup time, so synccall is probably > not needed to get a sp I just meant if we want the API to work in general... > to get a 'precize' lowend one can: > 1) parse /proc/self/maps which gives the current [low,high] mapping > and 'prev' the high end of the last mapping below the stack > 2) if we are the main thread check if low <= sp <= high > 3) check rlimit Parsing /proc/self/maps is utterly useless for non-main-thread. Unless the thread has a guard page, its stack mapping can be adjacent to another thread's stack mapping, and thus they can get merged into a single mapping. Rich