comp.lang.ada
 help / color / mirror / Atom feed
From: Dennis Hoppe <dennis.hoppe@hoppinet.de>
Subject: Error: "could not understand bounds information on packed array"
Date: Fri, 29 May 2009 02:55:23 +0200
Date: 2009-05-29T02:55:23+02:00	[thread overview]
Message-ID: <gvnbq7$m43$1@aioe.org> (raw)

Hi,

I am getting the following error message while executing my program:

Execution terminated by unhandled exception
Exception name: STORAGE_ERROR
Message: stack overflow

By use of gdb, I am getting some more useful information like

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5f3fffd0
0x0000000100027cde in my_procedure (input_a=warning: could not 
understand bounds information on packed array
can't unpack array
, input_b=warning: could not understand bounds information on packed 
array can't unpack array
, input_c=can't unpack array
, input_d=can't unpack array
, input_e=0, output=) at my_package.adb:143
143	    procedure myprocedure (input_a : in     Bit_Field;


I am using the following data types ...

type Word is mod 2**64;
for Word'Size use 64;
pragma Volatile(Word);

type Bit is new Natural range 0 .. 1;
type Bit_Number is new Natural range 0 .. Word'Size - 1;
type Bit_Field is array (Bit_Number) of Boolean;

for Bit_Field'Component_Size use 1;

... and conversions ...

function To_Bit_Field is
   new Ada.Unchecked_Conversion (Source => Word, Target => Bit_Field);

function To_Word is
   new Ada.Unchecked_Conversion (Source => Bit_Field, Target => Word);


Snippet:

procedure my_procedure
   (input_a : in     Bit_Field;
    input_b : in     Bit_Field;
    input_c : in out Bit_Field;
    input_d : in out Bit_Field;
    index   : in     Natural;
    output  : in out Word_Vector.Vector) is
begin
   if index = Bit_Field'Length then
     Word_Vector.Append (output, To_Word(input_c));
   else
     -- do something
     -- recursive call
     my_procedure(input_a, input_b, input_c, input_d, index+1, output);
   end if;
end my_procedure;


Currently, I am appending exactly eight elements to the vector. So, no 
Storage_Error could be raised based on too much elements.


The procedure, which causes the error is recursive. A new Word will be 
constructed bitwise and in the end, the Word will be appended to a vector.

First, I thought, the error may be raised due to the unchecked 
conversions (cf. "can't unpack array"). However, I am using the 
unchecked conversion just once in the termination clause. Uncommenting 
the conversion does not help.

Then, I am stumbled upon "EXC_BAD_ACCESS, Could not access memory". 
Additionally, the error message differs from time to time (if I compile 
with or without optimization, with or without -fstack-check):

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00007fff5f3fffe0
0x00007fff82d91b28 in szone_malloc ()
(gdb) backtrace
#0  0x00007fff82d91b28 in szone_malloc ()
#1  0x00007fff82d91aef in malloc_zone_malloc ()
#2  0x00007fff82d91a80 in malloc ()
#3  0x000000010006da5f in __gnat_malloc ()
#4  0x0000000100025f48 in word_vector.insert (container=, before=0, 
new_item=16, count=<value temporarily unavailable, due to 
optimizations>) at a-convec.adb:829
#5  0x0000000100026488 in word_vector.append (container=, 
new_item=9223654062804208200, count=1598043600) at a-convec.adb:316


This may be caused in the termination clause, where I try to append the 
new Word to a vector. It is interesting, that call #5 and #4 has another 
value for "new_item", although insert is called in the body of append.

At the moment, I am wondering, if my computer has some memory issues.


I know, the problem is hard to understand. I would like to provide a 
minimal code snippet to demonstrate the failure, but the whole program 
is very complex. I tried to take the parameters given by the debugger -- 
recovered by means of backtracing -- directly as input to the procedure. 
But no error occurs at all, if I call the problematic procedure solely.


Best regards,
   Dennis Hoppe



             reply	other threads:[~2009-05-29  0:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29  0:55 Dennis Hoppe [this message]
2009-05-29  1:13 ` Error: "could not understand bounds information on packed array" Dennis Hoppe
2009-05-29 11:58   ` Dennis Hoppe
2009-05-29 11:56     ` Per Sandberg
2009-05-29 13:02     ` John B. Matthews
2009-05-29 13:46       ` Dennis Hoppe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox