comp.lang.ada
 help / color / mirror / Atom feed
* STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
@ 2007-04-02  6:13 andrew.carroll
  2007-04-02 10:10 ` Stephen Leake
                   ` (3 more replies)
  0 siblings, 4 replies; 46+ messages in thread
From: andrew.carroll @ 2007-04-02  6:13 UTC (permalink / raw)


I read the messages earlier on this error where they were working on
some medical device.  My program is not threaded.  I'm not real sure
where to put a pragma storage_size(...) statement.  Does it go inside
the procedure of the main program?  Does it go in the package header?
The package body?  Where should I put it?  Okay, you caught me, I
tried all of those and the compiler wouldn't let me put them there.
How do I use heap instead when allocating an object?  Is it some other
word than "new" or just a pragma?

I didn't have trouble with this until I started using 'class types
instead of _ptr "types".  I am trying to use ada.streams.stream_io
with dispatching.  I wasn't using dispatching originally.  In the
newest version, with dispatching, I made my base type abstract,
changed from using _ptr "types" to 'class types and then I would get
the message "raised PROGRAM_ERROR : EXCEPTION_ACCESS_VIOLATION".  So I
kept converting things from _ptr to 'class thinking that maybe a tag
wasn't written or that it was due to some inconsistency between
'outputing an _ptr and 'inputing a 'class.

I tracked it down to one section of my code that uses 'input to read
the object from a file stream.  After it is 'inputed the data is all
messed up.  The section of code is where I capture the return value of
the return value of the call to from_disc (which is a dispatched
call).  Anyway, now that I've muddied that up.  HELP!

Here are the base types and all that:

with util, Ada.Calendar, ada.streams.stream_io;

use util, Ada.Calendar, ada.streams.stream_io;

package attribute_types is

    -----------------------------------
    --    Forwarding Declarations    --
    -----------------------------------
    type attribute is abstract tagged;
    type booleanattribute is tagged;
    type integerattribute is tagged;
    type stringattribute is tagged;
    type dateattribute is tagged;

    --------------------------------------
    --    Attribute Type Declarations    --
    --------------------------------------
    type attribute is abstract tagged record
        name         : String (1 .. max_attributename_length) :=
           (1 .. max_attributename_length => ' ');
        domain       : String (1 .. max_typename_length) := (1 ..
max_typename_length => ' ');
        isprimarykey : Boolean                                :=
False;
        byte_start   : Integer                                := 0;
        byte_end     : Integer                                := 0;
    end record;

    --------------------------------------
    --    Basic Pointer Declarations    --
    --------------------------------------
    type attribute_ptr is access attribute'class;
    --type attribute_array is array (Integer range <>) of
attribute_ptr;
    type attribute_array is array (Integer range <>) of access
attribute'class;
    type attribute_array_ptr is access all attribute_array;

    procedure to_disc (fout: file_type; item: in out attribute) is
abstract;
    function from_disc(fout: file_type; item: attribute) return
attribute'class is abstract;


    -----------------------------------
    --    Extended Attribute Types   --
    -----------------------------------
    type booleanattribute is new attribute with record
        value : Boolean := False;
    end record;
    type booleanattribute_ptr is access all booleanattribute'class;
    procedure to_disc (fout: file_type; item: in out
booleanattribute);
    function from_disc(fin: file_type; item: booleanattribute) return
attribute'class;

    type integerattribute is new attribute with record
        value : Integer := 0;
    end record;
    type integerattribute_ptr is access all integerattribute'class;
    procedure to_disc (fout: file_type; item: in out
integerattribute);
    function from_disc(fin: file_type; item: integerattribute) return
attribute'class;

    type stringattribute is new attribute with record
        value : String (1 .. max_stringlength) := (1 ..
max_stringlength => ' ');
    end record;
    type stringattribute_ptr is access all stringattribute'class;
    procedure to_disc (fout: file_type; item: in out stringattribute);
    function from_disc(fin: file_type; item: stringattribute) return
attribute'class;

    type dateattribute is new attribute with record
        year  : Year_Number  := 1901;
        month : Month_Number := 1;
        day   : Day_Number   := 1;
        value : Time         := Time_Of (1901, 1, 1);
    end record;
    type dateattribute_ptr is access all dateattribute'class;
    procedure to_disc (fout: file_type; item: in out dateattribute);
    function from_disc(fin: file_type; item: dateattribute) return
attribute'class;

end attribute_types;


with ada.text_io, util, ada.calendar;
use util, ada.calendar;

package body attribute_types is

    procedure to_disc (fout: file_type; item: in out booleanattribute)
is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(booleanattribute'size / 8) - 7;
        booleanattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: booleanattribute) return
attribute'class is
        temp : access attribute'class;
    begin
      temp := new booleanattribute;
      temp.all := booleanattribute'class'input (Stream (fin));
      return temp.all;
    end from_disc;

    procedure to_disc (fout: file_type; item: in out integerattribute)
is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(integerattribute'size / 8) - 7;
        integerattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: integerattribute) return
attribute'class is
    	temp : access attribute'class;
    begin
  	temp := new integerattribute;
	temp.all := integerattribute'class'input (Stream (fin));
	return temp.all;
    end from_disc;

    procedure to_disc (fout: file_type; item: in out stringattribute)
is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(stringattribute'size / 8) - 7;
        stringattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: stringattribute) return
attribute'class is
    	temp: access attribute'class;
    begin
  	temp := new stringattribute;
	temp.all := stringattribute'class'input (Stream (fin));
	return temp.all;
    end from_disc;

    procedure to_disc (fout: file_type; item: in out dateattribute) is
    begin
        item.byte_start := Integer'val (Index (fout));
        item.byte_end := Integer'val (Index (fout)) +
(dateattribute'size / 8) - 11;
        dateattribute'class'output(Stream(fout), item);
    end to_disc;

    function from_disc(fin: file_type; item: dateattribute) return
attribute'class is
    	temp: access attribute'class;
    begin
    	temp := new dateattribute;
	temp.all := dateattribute'class'input (Stream (fin));
	return temp.all;
    end from_disc;

begin
    null;
end attribute_types;

with attribute_types...
use attribute_types...
package schema_types is
...
    type schema (number_of_attributes : Integer) is tagged record
        tablename : String (1 .. max_tablename_length) := (1 ..
max_tablename_length => ' ');

        --attribute order is always from left to right
        --Primary key attributes | others
        attributes        : attribute_array (1 ..
number_of_attributes);
        byte_start        : Integer := 0;
        byte_end          : Integer := 0;
        primary_key_count : Integer := 0;
    end record;
...
end schema_types;

Here is the code that initiates disaster:
schemainfo.all.attributes (x) := new attribute'class'(from_disc(fin,
schemainfo.all.attributes (x).all));




^ permalink raw reply	[flat|nested] 46+ messages in thread
* STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
@ 2005-08-05  0:55 Adaddict
  2005-08-05  1:21 ` Adaddict
  0 siblings, 1 reply; 46+ messages in thread
From: Adaddict @ 2005-08-05  0:55 UTC (permalink / raw)


Greetings,
I'm doing a small program that uses a search function. That search
function compares a given string with the strings returned by a second
function until that second function can't return another string.
During the execution of that search I get that error. Does anyone know
what causes it and how could I solve it?

P.S: Using GNAT 3.15p on AdaGIDE to develop a Win32 app.




^ permalink raw reply	[flat|nested] 46+ messages in thread
[parent not found: <20050709100024.322314C41FD@lovelace.ada-france.org>]
[parent not found: <200507082148.j68LmXhG002695@mail733.megamailservers.com>]
* STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW
@ 2005-07-08 21:48 Robert C. Leif
  2005-07-09  3:52 ` John B. Matthews
                   ` (3 more replies)
  0 siblings, 4 replies; 46+ messages in thread
From: Robert C. Leif @ 2005-07-08 21:48 UTC (permalink / raw)
  To: Comp. Lang. Ada

   I am creating software in Ada to visualize images obtained with a
fluorescence microscope. Unfortunately, when I switch my images from having
16 bit pixels to 32 bit pixels, I raise the exception STORAGE_ERROR :
EXCEPTION_STACK_OVERFLOW.
   I am using GNAT 3.15p.
   The Users Guide to Windows states: "5.3 Setting Stack Size from gnatlink 
   It is possible to specify the program stack size from gnatlink. Assuming
that the underlying linker is GNU ld there is two ways to do so: 
   using -Xlinker linker option 
     $ gnatlink hello -Xlinker --stack=0x10000,0x1000
   This set the stack reserve size to 0x10000 bytes and the stack commit
size to 0x1000 bytes. 
   using -Wl linker option 
     $ gnatlink hello -Wl,--stack=0x1000000
   This set the stack reserve size to 0x1000000 bytes. Note that with -Wl
option it is not possible to set the stack commit size because the coma is a
separator for this option."
   My project file includes:
   
   package Linker is
      for Default_Switches ("ada") use ("-g", "-Xlinker
stack=0x10000000,0x10000000");
      end Linker;
   
   Even with a 10 megabyte stack, I still get Stack_Overflow.
   Any suggestions would be greatly appreciated.  I believe that I know how
to put the array on the heap using an access type.  However, I greatly
prefer working with objects that are on the stack and omitting pointers from
my code.
   Thank you.
   Bob Leif




^ permalink raw reply	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2007-04-12 19:08 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-02  6:13 STORAGE_ERROR : EXCEPTION_STACK_OVERFLOW andrew.carroll
2007-04-02 10:10 ` Stephen Leake
2007-04-02 14:11   ` andrew.carroll
2007-04-02 18:43     ` andrew.carroll
2007-04-02 21:48       ` Georg Bauhaus
2007-04-02 21:40         ` andrew.carroll
2007-04-03 10:25           ` Georg Bauhaus
2007-04-03 17:07             ` andrew.carroll
2007-04-03 19:43             ` Simon Wright
2007-04-03 21:32               ` andrew.carroll
2007-04-04  0:49               ` Georg Bauhaus
2007-04-04  0:32                 ` andrew.carroll
2007-04-05 18:28                   ` Georg Bauhaus
2007-04-09 13:12                     ` andrew.carroll
2007-04-09 18:19                       ` Georg Bauhaus
2007-04-10 13:22                         ` andrew.carroll
2007-04-10 15:07                           ` Ludovic Brenta
2007-04-10 20:55                             ` andrew.carroll
2007-04-10 22:17                               ` Georg Bauhaus
2007-04-10 21:43                                 ` andrew.carroll
2007-04-12  8:32                                   ` Ludovic Brenta
2007-04-11  1:55                               ` Jeffrey R. Carter
2007-04-11  2:34                                 ` andrew.carroll
2007-04-05  0:56                 ` andrew.carroll
2007-04-02 20:45     ` Simon Wright
2007-04-02 21:47       ` andrew.carroll
2007-04-02 22:05 ` andrew.carroll
2007-04-03  0:09   ` Randy Brukardt
2007-04-11  2:49 ` andrew.carroll
2007-04-11  8:07   ` Georg Bauhaus
2007-04-11 21:31   ` Simon Wright
2007-04-12 16:00     ` andrew.carroll
2007-04-12 19:08       ` Simon Wright
2007-04-12 13:48 ` andrew.carroll
2007-04-12 15:49   ` Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2005-08-05  0:55 Adaddict
2005-08-05  1:21 ` Adaddict
     [not found] <20050709100024.322314C41FD@lovelace.ada-france.org>
2005-07-09 12:29 ` Robert C. Leif
     [not found] <200507082148.j68LmXhG002695@mail733.megamailservers.com>
2005-07-09  9:27 ` Marius Amado Alves
2005-07-09 19:14 ` Duncan Sands
2005-07-08 21:48 Robert C. Leif
2005-07-09  3:52 ` John B. Matthews
2005-07-12  0:29   ` jim hopper
2005-07-09 22:55 ` Björn Persson
2005-07-11 10:15 ` Alex R. Mosteo
2005-07-11 20:07 ` Keith Thompson

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