* "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
@ 2015-02-27 19:26 jocpaine
2015-02-28 10:08 ` Simon Wright
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: jocpaine @ 2015-02-27 19:26 UTC (permalink / raw)
Hi. I've defined a queue type by instantiating Ada.Containers.Bounded_Synchronized_Queues . When I define a record with a field of that type, and then declare a variable of the record type, I get the storage error mentioned in the email subject line. That happens even if I never use the variable. However, if my variable is the queue type, I don't get the error. I'm surprised at that, because I'd expect a one-field record to have exactly the same storage layout as its field, so if one provokes the error, so should the other. That aside though, can anyone suggest a fix?
Google shows me that similar errors have been reported before (not with the queue types): for example https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42816 , "Bug 42816 - Crash in Ada.Containers.Vectors.Update_Element".
I'm using Gnat Ada 2014: specifically, gnatmake GPL 2014 (20140331) on Ubuntu 14.10 on version 3.16.0-30-generic of the Linux kernel. My program is below. I compiled it by doing
gnatmake q11
from the file q11.adb . Running it by doing
./q11
gives the error.
Here's the program:
with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Bounded_Synchronized_Queues;
procedure Q11 is
package Job_Queues_Interface is
new Ada.Containers.Synchronized_Queue_Interfaces
( Element_Type => Integer );
package Job_Queues_Package is
new Ada.Containers.Bounded_Synchronized_Queues
( Queue_Interfaces => Job_Queues_Interface
, Default_Capacity => 100
);
subtype My_Queue_Type is Job_Queues_Package.Queue;
type Job_Queue is record
Queue: My_Queue_Type;
end record;
q : Job_Queue;
-- This is the line causing the error. If I give q
-- My_Queue_Type instead, the error doesn't happen.
begin
NULL;
end;
Thanks
Jocelyn Ireson-Paine
www.j-paine.org
www.jocelyns-cartoons.uk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
2015-02-27 19:26 "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
@ 2015-02-28 10:08 ` Simon Wright
2015-02-28 21:59 ` Stephen Leake
2015-03-02 8:55 ` Egil H H
2 siblings, 0 replies; 5+ messages in thread
From: Simon Wright @ 2015-02-28 10:08 UTC (permalink / raw)
GCC 4.9.1 gives a similar error (here, Mac OS X, it's Constraint_Error):
GCC 5.0.0 doesn't.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
2015-02-27 19:26 "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
2015-02-28 10:08 ` Simon Wright
@ 2015-02-28 21:59 ` Stephen Leake
2015-03-01 12:07 ` AdaMagica
2015-03-02 8:55 ` Egil H H
2 siblings, 1 reply; 5+ messages in thread
From: Stephen Leake @ 2015-02-28 21:59 UTC (permalink / raw)
jocpaine@googlemail.com writes:
> with Ada.Containers.Synchronized_Queue_Interfaces;
> with Ada.Containers.Bounded_Synchronized_Queues;
>
> procedure Q11 is
>
> package Job_Queues_Interface is
> new Ada.Containers.Synchronized_Queue_Interfaces
> ( Element_Type => Integer );
>
> package Job_Queues_Package is
> new Ada.Containers.Bounded_Synchronized_Queues
> ( Queue_Interfaces => Job_Queues_Interface
> , Default_Capacity => 100
> );
>
> subtype My_Queue_Type is Job_Queues_Package.Queue;
>
> type Job_Queue is record
> Queue: My_Queue_Type;
> end record;
>
> q : Job_Queue;
> -- This is the line causing the error. If I give q
> -- My_Queue_Type instead, the error doesn't happen.
The declaration of Queue in Ada.Containers.Bounded_Synchronized_Queues
includes:
protected type Queue
(Capacity : Count_Type := Default_Capacity;
Ceiling : System.Any_Priority := Default_Ceiling)
with
Priority => Ceiling
is new Queue_Interfaces.Queue with
...
private
List : Implementation.List_Type (Capacity);
end Queue;
List_Type is:
type List_Type (Capacity : Count_Type) is tagged limited record
First, Last : Count_Type := 0;
Length : Count_Type := 0;
Max_Length : Count_Type := 0;
Elements : Element_Array (1 .. Capacity) := (others => <>);
end record;
So if Capacity is large enough, you'll get Storage_Error.
In type Queue, the discriminant Capacity has a default value, which
means it is allowed to be changed, in particular to Count_Type'last,
which is large enough to cause Storage_Error.
If you change Default_Capacity to 2**31-1, you get Storage_Error for
either case.
So apparently GNAT allocates the largest allowed space when you use type
Job_Queue, but when you use the type My_Queu_Type, it allocates the
space needed for the current discriminant.
--
-- Stephe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
2015-02-28 21:59 ` Stephen Leake
@ 2015-03-01 12:07 ` AdaMagica
0 siblings, 0 replies; 5+ messages in thread
From: AdaMagica @ 2015-03-01 12:07 UTC (permalink / raw)
Am Samstag, 28. Februar 2015 22:59:47 UTC+1 schrieb Stephen Leake:
> In type Queue, the discriminant Capacity has a default value, which
> means it is allowed to be changed,
No, I think Queue is limited, so the discriminant cannot be changed.
> in particular to Count_Type'last,
> which is large enough to cause Storage_Error.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014
2015-02-27 19:26 "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
2015-02-28 10:08 ` Simon Wright
2015-02-28 21:59 ` Stephen Leake
@ 2015-03-02 8:55 ` Egil H H
2 siblings, 0 replies; 5+ messages in thread
From: Egil H H @ 2015-03-02 8:55 UTC (permalink / raw)
For what it's worth: On a 32-bit platform I get
- warning: "STORAGE_ERROR" will be raised at run time
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-02 8:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-27 19:26 "STORAGE_ERROR : s-intman.adb:139 explicit raise" from record containing a queue from Ada.Containers.Bounded_Synchronized_Queues in Gnat Ada 2014 jocpaine
2015-02-28 10:08 ` Simon Wright
2015-02-28 21:59 ` Stephen Leake
2015-03-01 12:07 ` AdaMagica
2015-03-02 8:55 ` Egil H H
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox