From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26799 invoked from network); 28 Jun 2022 14:21:31 -0000 Received: from tb-ob0.topicbox.com (64.147.108.117) by inbox.vuxu.org with ESMTPUTF8; 28 Jun 2022 14:21:31 -0000 Received: from tb-mx0.topicbox.com (tb-mx0.nyi.icgroup.com [10.90.30.73]) by tb-ob0.topicbox.com (Postfix) with ESMTP id 770BE28DE5 for ; Tue, 28 Jun 2022 10:21:28 -0400 (EDT) (envelope-from bounce.mMcbc484781129f693c26365ef.r522be890-2105-11eb-b15e-8d699134e1fa@9fans.bounce.topicbox.com) Received: by tb-mx0.topicbox.com (Postfix, from userid 1132) id 197DA2A45020; Tue, 28 Jun 2022 10:21:28 -0400 (EDT) ARC-Authentication-Results: i=2; topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type:list-help:list-id :list-post:list-subscribe:reply-to:content-transfer-encoding :list-unsubscribe; s=sysmsg-1; t=1656426087; bh=ESWznnPAlTufYk3y 9ZLYnjV4H/Cqbg5woRCR2DTXnJ8=; b=IaHMnj1GcaigQ2Bnp9+gdPeLT6m5nEfT xBlYxIV+ybQ3yjYJY1x0Q5eY8dG4rHCh11KkpxrG5JfTn7379jFE+NeQKbyy19Nc sQ/EEAnbvLXFe0axvTZxTJvxdauB1xWboZmfZKqKWsUxuyVg2eQKR2QVtfMNt9F+ iLw+kmGDBQo= ARC-Seal: i=2; a=rsa-sha256; cv=pass; d=topicbox.com; s=sysmsg-1; t= 1656426087; b=YUM26cVCipiUKafp5RHl8B0qeQXzX7HkjbvLsbafsNQY8jMMgo t2p3rL+Kj0Hh0fjqEMrg4BCSmHhTsTZ6XQ0icppWrKdcBzHhqa7LSWPWajG+3K7M LcPCyqF8c7Zl9Re8VuTqXYyzeY9wl9PowNnNqh/Hnc19ZLben+AFuymdQ= Authentication-Results: topicbox.com; arc=pass; dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-internal-arc=fail (as.1.topicbox.com=pass, ams.1.topicbox.com=fail (message has been altered)) (Message modified while forwarding at Topicbox) X-Received-Authentication-Results: tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=9fans.net; h=date:from :to:subject:in-reply-to:message-id:references:mime-version :content-type:list-help:list-id:list-post:list-subscribe :reply-to:content-transfer-encoding:list-unsubscribe; s=dkim-1; t=1656426087; x=1656512487; bh=VCaeQIPuRRUxzi8oO1Wh8ru2YR3JZP6q BXwJKlVFLiY=; b=DOeOvh8xm8LE+kkMX3s5QlQM41IUaxs3DoVQO1bgLyn2xKym 8UhjAd4Sn5iEZuWJvTmb1Xc0znSAmGnjO5OpFS4FdKIzRaDnFl+9FvR+ve6ZULp8 ZcJthSf0nyrI7avdQvfguSaL2zORd36azZ6bbG0HT2iNWDNf+eeFej54HoE= Received: from tb-mx0.topicbox.com (localhost.local [127.0.0.1]) by tb-mx0.topicbox.com (Postfix) with ESMTP id BB68F2A44C03 for <9fans@9fans.net>; Tue, 28 Jun 2022 10:21:15 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from tb-mx0.topicbox.com (localhost [127.0.0.1]) by tb-mx0.topicbox.com (Authentication Milter) with ESMTP id 96F474F1245; Tue, 28 Jun 2022 10:21:15 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1656426075; b=h29Tu6Pyx1kxsZcnKtnXFNHsAhsiPJFPwOC2fsYN5Bfjs6fm+C FwIxLxgTZK4IDNXpUvH6IeQCheQLEG4sBlzFscbzjZdxaYpW1ov4N3X8RRDN0I0R LAXQlGCEjOUsKlGJPMI3si2hqOSa7oQaun1EYhgAOCKgJ44mNcmsKG0uQN7+X3VX JY6+WpbJizMMsPwlSIvdGU4JO7Rhcx7WjWpZl1TWOhaJrdOUmXXaHVjX1dWXOqca NW2Metd28b7t8xWFwmtvdjTMxDpsmvcZZDfuHqLe8O8z1YWvZuurLlkoFE6NnELu Cv0W3hFLF5jRCY/Zjp7ObB/R1G6TtnLTbaoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type; s=arcseal; t=1656426075; bh=s4MQTEB8Wz4QyY2kbWP4fFe4Uk0QEuLEwKZ1BdTi39U=; b=g4Ltz5QESCnJ X8cPrUbg8En5pY5AFZOmUfzssyj8SKA4CJfbfvdCrKGZJF7ZEgar2Q2AYdsaSoUZ GoZ7OucrRDfRC9VEdjKugj8v+DJFpqyNrEVqQ9N+ff2uMz5olyRAwYmEw6ARjTTr eXHf5WzS/cfMyF1sBCrFDEsRcMP08zLATqTQLqHATDdDxeyRxmSjv3HomfaXepQg hX1Cw9B2oud34Cq0K0FODw6aI38k1B032KSC5K2D6qqOE7Y4BJizAChUfM6gkpTW Wgfx8Xfos/dKP26vUiYPNcqnCxPxEusaOWVCVyElhCYqS0JpHH+fzD9kwrK5b08f bb0fLQ2whQ== ARC-Authentication-Results: i=1; tb-mx0.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC Policy is not at enforcement); dkim=none (no signatures found); dmarc=pass policy.published-domain-policy=none policy.published-subdomain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none (p=none,sp=none,d=none,d.eval=none) policy.policy-from=p header.from=sdf.org; iprev=pass smtp.remote-ip=205.166.94.24 (mx.sdf.org); spf=pass smtp.mailfrom=adr@SDF.ORG smtp.helo=mx.sdf.org; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=mx.sdf.org policy.ptr=mx.sdf.org; x-return-mx=pass header.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-return-mx=pass smtp.domain=sdf.org policy.is_org=yes (MX Records found: mx.sdf.org); x-tls=pass smtp.version=TLSv1.2 smtp.cipher=ECDHE-RSA-AES256-GCM-SHA384 smtp.bits=256/256; x-vs=clean score=0 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvfedrudegjedgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuf gjkfhfgggtsehttdertddttddvnecuhfhrohhmpegrughruceorggurhesufffhfdrqfft ifeqnecuggftrfgrthhtvghrnhepkeehtdevffehvefhtdeghfehgfevleevudejteejtd ehuddvfedvkeegtdffhfffnecukfhppedvtdehrdduieeirdelgedrvdegpddvtdehrddu ieeirdelgedrudeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvth epvddthedrudeiiedrleegrddvgedphhgvlhhopehmgidrshgufhdrohhrghdpmhgrihhl fhhrohhmpeeorggurhesufffhfdrqfftifeq X-ME-VSScore: 0 X-ME-VSCategory: clean Received-SPF: pass (sdf.org: 205.166.94.24 is authorized to use 'adr@SDF.ORG' in 'mfrom' identity (mechanism 'ip4:205.166.94.0/24' matched)) receiver=tb-mx0.topicbox.com; identity=mailfrom; envelope-from="adr@SDF.ORG"; helo=mx.sdf.org; client-ip=205.166.94.24 Received: from mx.sdf.org (mx.sdf.org [205.166.94.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tb-mx0.topicbox.com (Postfix) with ESMTPS for <9fans@9fans.net>; Tue, 28 Jun 2022 10:21:15 -0400 (EDT) (envelope-from adr@SDF.ORG) Received: from sdf.org (IDENT:adr@sdf.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 25SELD0i023329 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO) for <9fans@9fans.net>; Tue, 28 Jun 2022 14:21:14 GMT Received: from localhost (adr@localhost) by sdf.org (8.15.2/8.12.8/Submit) with ESMTP id 25SELDCM004377 for <9fans@9fans.net>; Tue, 28 Jun 2022 14:21:13 GMT Date: Tue, 28 Jun 2022 14:21:13 +0000 (UTC) From: adr To: 9fans <9fans@9fans.net> Subject: Re: [9fans] Re: _threadmalloc() size>100000000; shouldn't be totalmalloc? In-Reply-To: Message-ID: References: <7eea6efa-711a-31dc-031-dc5c2eddce3d@SDF.ORG> <7f0986f-5958-de7-68b6-8cd49f94e191@SDF.ORG> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 94dc4ea4-f6ed-11ec-8211-c4f0636a557b Archived-At: =?UTF-8?B?PGh0dHBzOi8vOWZhbnMudG9waWNib3guY29tL2dyb3Vwcy85?= =?UTF-8?B?ZmFucy9UZTFiZThkYzcyNzM4MjU4ZC1NY2JjNDg0NzgxMTI5ZjY5M2MyNjM2?= =?UTF-8?B?NWVmPg==?= List-Help: List-Id: "9fans" <9fans.9fans.net> List-Post: List-Software: Topicbox v0 List-Subscribe: Precedence: list Reply-To: 9fans <9fans@9fans.net> Content-Transfer-Encoding: quoted-printable List-Unsubscribe: , Topicbox-Delivery-ID: 2:9fans:437d30aa-c441-11e9-8a57-d036212d11b0:522be890-2105-11eb-b15e-8d699134e1fa:Mcbc484781129f693c26365ef:1:yIQ8mJhWk99_c-Sn6bOT6myndNzUPGVD6ZQ-zP_6CxA On Tue, 28 Jun 2022, Dan Cross wrote: >>> [...] >>> void* >>> _threadmalloc(long size, int z) >>> { >>> void *m; >>> >>> m =3D malloc(size); >>> if (m =3D=3D nil) >>> sysfatal("Malloc of size %ld failed: %r", size); >>> setmalloctag(m, getcallerpc(&size)); >>> totalmalloc +=3D size; >>> if (size > 100000000) { >>> fprint(2, "Malloc of size %ld, total %ld\n", size, >>> totalmalloc); >>> abort(); >>> } >>> if (z) >>> memset(m, 0, size); >>> return m; >>> } >>> [...] >>> >>> Shouldn't the if statement test the size of totalmalloc before the >>> abort? That size, 100M for internal allocations? It has to be >>> totalmalloc, doesn't it? If not this if statement should be after >>> testing the success of the malloc. Am I missing something? > > Note that the `if` statement doesn't test the size of *totalmalloc*, but > just `size`. `totalsize` is only incidentally printed in the output if `= size` > exceeds 100 MB: that is, if a single allocation is larger than 100MB. I know, what called my attention is that size wasn't tested before calling malloc, so the first thought I had was that the code had a typo and it should be testing totalmalloc instead. >> I mean, I think using libthread more like using small channels and threa= d's stack sizes, but: >> >> Why put a limit here to size when totalmalloc could continue to grow unt= il malloc fails? >> >> If we want a limit, why don't we take into account the system resources? >> >> If we want a constant limit, why don't we put it on threadimpl.h, explai= n why this value in a comment >> and document it in thread(2)? >> >> Why bother to call malloc before testing if size exeeds that limit??? > > Given the name of the function (`_threadmalloc`), I'd guess that this isn= 't > intended for general use, but rather, for the internal consumption of the > thread library, where indeed such a large allocation would likely be an > error (bear in mind this code was developed on 32-bit machines with RAMs > measured in Megabytes, not Gigabytes). No, it's used also when creating a channel and setting a thread's stack size. adr ------------------------------------------ 9fans: 9fans Permalink: https://9fans.topicbox.com/groups/9fans/Te1be8dc72738258d-Mcbc48= 4781129f693c26365ef Delivery options: https://9fans.topicbox.com/groups/9fans/subscription