From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.13.196.66 with SMTP id g63mr1876444ywd.140.1476884073463; Wed, 19 Oct 2016 06:34:33 -0700 (PDT) X-Received: by 10.157.7.111 with SMTP id 102mr935322ote.17.1476884073425; Wed, 19 Oct 2016 06:34:33 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!g45no222995qte.1!news-out.google.com!203ni730itk.0!nntp.google.com!e187no241560itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 19 Oct 2016 06:34:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=193.71.175.207; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn NNTP-Posting-Host: 193.71.175.207 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <28631525-d397-4bd4-85be-2a264b59339e@googlegroups.com> Subject: Re: Bug in GNAT? - Max_size_in_storage_elements insufficient From: Egil H H Injection-Date: Wed, 19 Oct 2016 13:34:33 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:32135 Date: 2016-10-19T06:34:31-07:00 List-Id: Using Max_Size_In_Storage_Elements in this way is asking for trouble, and n= ot at all portable, as the actual storage needed may depend on Alignment an= d fragmentation. However, looking at GNAT's implementation (GNATPro 7.4.1), there are a coup= le quirks; First off, the storage pool used by GNAT in this case ends up in a buffer o= n the stack. Unallocated parts of the buffer is implemented as a kind of ov= erlayed linked list of chunks. This list always needs at least one root nod= e, with a size field and pointer to the next node (on my 64 bit machine, th= e node is a total of 16 storage_elements), so that's several bytes worth of= extra space needed, which 'Max_Size_In_Storage_Elements does not (and can = not) take into account. I'll leave it up to AdaCore to answer whether this = is the intended behaviour. Secondly, when allocating an object in the pool, there is a search for a la= rge enough chunk. This search checks if the chunk size is less than (not le= ss than or equal to) the requested size + alignment. So the actual chunk se= lected must be at least one byte larger than requested, which must be a bug= ... Knowing this, I got your code code working on my machine by doing Storage_Size =3D> (Num_Tasks * My_Task'Max_Size_In_Storage_Elements) + 17 This is of course not at all portable across compilers, not even across GNA= T versions... And certainly not portable across machine architectures.=20 So, one oddity and a likely bug... You may as well report it... --=20 ~egilhh