Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

C Code. C Code Run. Run, Code, RUN! PLEASE!!!!


devel / comp.lang.ada / Re: pragmas in doubly linked lists

SubjectAuthor
* pragmas in doubly linked listsL. B.
`* Re: pragmas in doubly linked listsNiklas Holsti
 `* Re: pragmas in doubly linked listsMario Blunk
  `* Re: pragmas in doubly linked listsEmmanuel Briot
   `* Re: pragmas in doubly linked listsMario Blunk
    `* Re: pragmas in doubly linked listsEmmanuel Briot
     `* Re: pragmas in doubly linked listsMario Blunk
      `- Re: pragmas in doubly linked listsMario Blunk

1
pragmas in doubly linked lists

<823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9295&group=comp.lang.ada#9295

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ae9:e40a:0:b0:702:2939:8cf5 with SMTP id q10-20020ae9e40a000000b0070229398cf5mr1863694qkc.75.1674757505384;
Thu, 26 Jan 2023 10:25:05 -0800 (PST)
X-Received: by 2002:a9d:1af:0:b0:684:e916:34fb with SMTP id
e44-20020a9d01af000000b00684e91634fbmr2064872ote.178.1674757505169; Thu, 26
Jan 2023 10:25:05 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Thu, 26 Jan 2023 10:25:04 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=87.143.117.164; posting-account=3zVVBwoAAAC7BSMfgNP7DSbqU9urpt40
NNTP-Posting-Host: 87.143.117.164
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
Subject: pragmas in doubly linked lists
From: mario.blunk.gplus@gmail.com (L. B.)
Injection-Date: Thu, 26 Jan 2023 18:25:05 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1448
 by: L. B. - Thu, 26 Jan 2023 18:25 UTC

Hello,

I'm having issues with cursors of doubly linked lists (erroneous memory access exceptions).
So I'm wondering whether the pragmas might solve the problems. What is the purpose of the pragmas defined in the package like

pragma Preelaborate(Doubly_Linked_Lists);
pragma Preelaborable_Initialization(List);
pragma Preelaborable_Initialization(Cursor);

What are they good for and how to use them ? Some simple examples would be very helpful. Thank you.

Re: pragmas in doubly linked lists

<k3ibmiFodb6U1@mid.individual.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9299&group=comp.lang.ada#9299

  copy link   Newsgroups: comp.lang.ada
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: niklas.holsti@tidorum.invalid (Niklas Holsti)
Newsgroups: comp.lang.ada
Subject: Re: pragmas in doubly linked lists
Date: Fri, 27 Jan 2023 18:16:18 +0200
Organization: Tidorum Ltd
Lines: 37
Message-ID: <k3ibmiFodb6U1@mid.individual.net>
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net qutU6Bin5I4M+mFICecI0g3KUpcOS813TDq+39Q083ihc9FLDK
Cancel-Lock: sha1:4SuctW0sQodOM4o1oq0ziQm67nA=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0)
Gecko/20100101 Thunderbird/102.6.1
Content-Language: en-US
In-Reply-To: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
 by: Niklas Holsti - Fri, 27 Jan 2023 16:16 UTC

On 2023-01-26 20:25, L. B. wrote:
> Hello,
>
> I'm having issues with cursors of doubly linked lists (erroneous
> memory access exceptions).

Sounds like a rather common programming error, perhaps trying to
dereference pointers that are null.

> So I'm wondering whether the pragmas might solve the problems.

That is very unlikely, IMO.

> What is the purpose of the pragmas defined in the package like
>
> pragma Preelaborate(Doubly_Linked_Lists);
> pragma Preelaborable_Initialization(List);
> pragma Preelaborable_Initialization(Cursor);

They tell the Ada compiler that the named package and the named types
will and should have very simple initialization requirements (default
initialization, for the types). They have no (visible) effect on how the
program executes and, AIUI, cannot be related to your memory access
exceptions.

For more explanation, see the Ada RM,
http://www.ada-auth.org/standards/22rm/html/RM-10-2-1.html.

If you would like help on the memory access exceptions, do describe the
problem more in detail here, and perhaps someone can help.

Re: pragmas in doubly linked lists

<5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9308&group=comp.lang.ada#9308

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:a954:0:b0:6ff:812e:9b55 with SMTP id s81-20020a37a954000000b006ff812e9b55mr1293261qke.4.1676103205694;
Sat, 11 Feb 2023 00:13:25 -0800 (PST)
X-Received: by 2002:a05:6808:13c3:b0:37d:75ae:a316 with SMTP id
d3-20020a05680813c300b0037d75aea316mr113194oiw.18.1676103205353; Sat, 11 Feb
2023 00:13:25 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sat, 11 Feb 2023 00:13:25 -0800 (PST)
In-Reply-To: <k3ibmiFodb6U1@mid.individual.net>
Injection-Info: google-groups.googlegroups.com; posting-host=87.155.207.50; posting-account=3zVVBwoAAAC7BSMfgNP7DSbqU9urpt40
NNTP-Posting-Host: 87.155.207.50
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com> <k3ibmiFodb6U1@mid.individual.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
Subject: Re: pragmas in doubly linked lists
From: mario.blunk.gplus@gmail.com (Mario Blunk)
Injection-Date: Sat, 11 Feb 2023 08:13:25 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1612
 by: Mario Blunk - Sat, 11 Feb 2023 08:13 UTC

> If you would like help on the memory access exceptions, do describe the
> problem more in detail here, and perhaps someone can help.

I'm thinking about writing a demo program to reproduce the problem. The actual project where the issue arises is way to complex.

I discovered that these problems occur in connection with doubly and indefinite doubly linked lists of cursors. The lists contain not elements but cursors to the elements of different containers.

Re: pragmas in doubly linked lists

<a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9309&group=comp.lang.ada#9309

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5c02:0:b0:3a8:15e1:757 with SMTP id i2-20020ac85c02000000b003a815e10757mr2435869qti.194.1676272932524;
Sun, 12 Feb 2023 23:22:12 -0800 (PST)
X-Received: by 2002:a05:6808:2195:b0:37d:5d11:1a74 with SMTP id
be21-20020a056808219500b0037d5d111a74mr885397oib.77.1676272932117; Sun, 12
Feb 2023 23:22:12 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 12 Feb 2023 23:22:10 -0800 (PST)
In-Reply-To: <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=88.160.66.39; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH
NNTP-Posting-Host: 88.160.66.39
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
<k3ibmiFodb6U1@mid.individual.net> <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com>
Subject: Re: pragmas in doubly linked lists
From: briot.emmanuel@gmail.com (Emmanuel Briot)
Injection-Date: Mon, 13 Feb 2023 07:22:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1834
 by: Emmanuel Briot - Mon, 13 Feb 2023 07:22 UTC

I believe the GNAT run time is still built without checks on. So it is quite possible that you have kept around cursors which
are no longer valid (those cursors are direct access types in practice), and GNAT has no way to test that.
In general, it is very dangerous to keep cursors outside of a very local context where you know exactly what is going on.

You could use vectors, instead of lists, and keep the corresponding index around (rather than a cursor directly) for instance.
But I would try and refactor the code to avoid having a container with cursors into another container, that seems fragile.

Re: pragmas in doubly linked lists

<a237856d-89ad-4b88-9313-265baff2bab4n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9311&group=comp.lang.ada#9311

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ac8:5f87:0:b0:3bb:7885:476f with SMTP id j7-20020ac85f87000000b003bb7885476fmr2129102qta.139.1676274024143;
Sun, 12 Feb 2023 23:40:24 -0800 (PST)
X-Received: by 2002:a05:6870:e887:b0:16e:151:1c70 with SMTP id
q7-20020a056870e88700b0016e01511c70mr317874oan.63.1676274023867; Sun, 12 Feb
2023 23:40:23 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 12 Feb 2023 23:40:23 -0800 (PST)
In-Reply-To: <a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.155.207.50; posting-account=3zVVBwoAAAC7BSMfgNP7DSbqU9urpt40
NNTP-Posting-Host: 87.155.207.50
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
<k3ibmiFodb6U1@mid.individual.net> <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
<a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a237856d-89ad-4b88-9313-265baff2bab4n@googlegroups.com>
Subject: Re: pragmas in doubly linked lists
From: mario.blunk.gplus@gmail.com (Mario Blunk)
Injection-Date: Mon, 13 Feb 2023 07:40:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 1949
 by: Mario Blunk - Mon, 13 Feb 2023 07:40 UTC

Emmanuel Briot schrieb am Montag, 13. Februar 2023 um 08:22:13 UTC+1:
> I believe the GNAT run time is still built without checks on. So it is quite possible that you have kept around cursors which
> are no longer valid (those cursors are direct access types in practice), and GNAT has no way to test that.
Thanks for your reply. All the cursors in my scenario are still valid. As far as I understood from John Barnes book Ada 2005, a cursor identifies the container and the item. In my case both the items and the containers still exist. So I assumed that collecting cursors in a list should work.

Re: pragmas in doubly linked lists

<f2479eb0-4fa6-4cc6-9cbe-eb94900adfacn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9312&group=comp.lang.ada#9312

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a37:2d02:0:b0:71a:23b2:e2 with SMTP id t2-20020a372d02000000b0071a23b200e2mr1468668qkh.139.1676274188650;
Sun, 12 Feb 2023 23:43:08 -0800 (PST)
X-Received: by 2002:aca:1218:0:b0:37b:8f4c:c230 with SMTP id
24-20020aca1218000000b0037b8f4cc230mr1384208ois.151.1676274188394; Sun, 12
Feb 2023 23:43:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Sun, 12 Feb 2023 23:43:08 -0800 (PST)
In-Reply-To: <a237856d-89ad-4b88-9313-265baff2bab4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=88.160.66.39; posting-account=6yLzewoAAABoisbSsCJH1SPMc9UrfXBH
NNTP-Posting-Host: 88.160.66.39
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
<k3ibmiFodb6U1@mid.individual.net> <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
<a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com> <a237856d-89ad-4b88-9313-265baff2bab4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f2479eb0-4fa6-4cc6-9cbe-eb94900adfacn@googlegroups.com>
Subject: Re: pragmas in doubly linked lists
From: briot.emmanuel@gmail.com (Emmanuel Briot)
Injection-Date: Mon, 13 Feb 2023 07:43:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 2171
 by: Emmanuel Briot - Mon, 13 Feb 2023 07:43 UTC

On Monday, February 13, 2023 at 8:40:25 AM UTC+1, Mario Blunk wrote:
> Thanks for your reply. All the cursors in my scenario are still valid. As far as I understood from John Barnes book Ada 2005, a cursor identifies the container and the item. In my case both the items and the containers still exist. So I assumed that collecting cursors in a list should work.

Fair enough,
The next things I would try (I am on linux, not sure what works on other platforms) are:
- valgrind to detect invalid memory access (that will immediately which cursor, if any, is accessing free memory and where that memory was freed)
- address sanitiser (asan) which does the same but so much faster. That requires recompiling your executable with `-fsanitizer=address` though

Re: pragmas in doubly linked lists

<181c7bf4-d3f8-47dd-b9b6-1e8301c46a12n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9428&group=comp.lang.ada#9428

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:a05:622a:341:b0:3e4:e17f:a544 with SMTP id r1-20020a05622a034100b003e4e17fa544mr5393688qtw.12.1680108399781;
Wed, 29 Mar 2023 09:46:39 -0700 (PDT)
X-Received: by 2002:a81:b149:0:b0:543:9065:b225 with SMTP id
p70-20020a81b149000000b005439065b225mr9817198ywh.5.1680108399571; Wed, 29 Mar
2023 09:46:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 29 Mar 2023 09:46:39 -0700 (PDT)
In-Reply-To: <f2479eb0-4fa6-4cc6-9cbe-eb94900adfacn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.155.203.225; posting-account=3zVVBwoAAAC7BSMfgNP7DSbqU9urpt40
NNTP-Posting-Host: 87.155.203.225
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
<k3ibmiFodb6U1@mid.individual.net> <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
<a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com> <a237856d-89ad-4b88-9313-265baff2bab4n@googlegroups.com>
<f2479eb0-4fa6-4cc6-9cbe-eb94900adfacn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <181c7bf4-d3f8-47dd-b9b6-1e8301c46a12n@googlegroups.com>
Subject: Re: pragmas in doubly linked lists
From: mario.blunk.gplus@gmail.com (Mario Blunk)
Injection-Date: Wed, 29 Mar 2023 16:46:39 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1787
 by: Mario Blunk - Wed, 29 Mar 2023 16:46 UTC

I've put together some examples to reproduce the problem in:
https://github.com/Blunk-electronic/ada_training/tree/master/src/containers/lists/lists_of_cursors
But, everything behaves as it should.

The examples store cursors of a single list. In another example (to follow in the next days) I will use multiple lists. Then the list of cursors contains cursors of more than one list.

Re: pragmas in doubly linked lists

<a07e95df-31e3-476e-87d6-a64ba8858326n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=9516&group=comp.lang.ada#9516

  copy link   Newsgroups: comp.lang.ada
X-Received: by 2002:ad4:5504:0:b0:5ea:25e:7b76 with SMTP id pz4-20020ad45504000000b005ea025e7b76mr240354qvb.1.1681888642664;
Wed, 19 Apr 2023 00:17:22 -0700 (PDT)
X-Received: by 2002:a25:3a04:0:b0:b96:7fb0:f927 with SMTP id
h4-20020a253a04000000b00b967fb0f927mr899431yba.12.1681888642457; Wed, 19 Apr
2023 00:17:22 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!peer02.ams4!peer.am4.highwinds-media.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.ada
Date: Wed, 19 Apr 2023 00:17:22 -0700 (PDT)
In-Reply-To: <181c7bf4-d3f8-47dd-b9b6-1e8301c46a12n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=87.143.122.5; posting-account=3zVVBwoAAAC7BSMfgNP7DSbqU9urpt40
NNTP-Posting-Host: 87.143.122.5
References: <823bfde7-adb3-4cd2-adca-744cf676864an@googlegroups.com>
<k3ibmiFodb6U1@mid.individual.net> <5176a59b-9224-45a0-a803-df1acf8ab8c7n@googlegroups.com>
<a2e4dd42-6adb-415b-8baa-379a2b42439cn@googlegroups.com> <a237856d-89ad-4b88-9313-265baff2bab4n@googlegroups.com>
<f2479eb0-4fa6-4cc6-9cbe-eb94900adfacn@googlegroups.com> <181c7bf4-d3f8-47dd-b9b6-1e8301c46a12n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a07e95df-31e3-476e-87d6-a64ba8858326n@googlegroups.com>
Subject: Re: pragmas in doubly linked lists
From: mario.blunk.gplus@gmail.com (Mario Blunk)
Injection-Date: Wed, 19 Apr 2023 07:17:22 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1712
 by: Mario Blunk - Wed, 19 Apr 2023 07:17 UTC

There is a demo program that reproduces a strange behavior. It could be related to the issue above. See:
https://groups.google.com/g/comp.lang.ada/c/eOtyCu7dQ_c/m/3drS5DHuBQAJ

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor