comp.lang.ada
 help / color / mirror / Atom feed
* I've not seen this error before
@ 2015-04-01  8:42 tonyg
  2015-04-01 13:08 ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: tonyg @ 2015-04-01  8:42 UTC (permalink / raw)



2015-04-01 09:19:32.10 : Exception name: PROGRAM_ERROR
Message: adjust/finalize raised PROGRAM_ERROR: device_type_pkg.ads:115 finalize/adjust raised exception

the code is an ada specification

 type Device_Details_Type is record
      Device_Id : Device_Index_Type;
      The_Device : Device_Class_Type;
      Room_Id : Room_Id_Type;
      The_Id : Domoticz_ID_Type;
      Battery_Level : Battery_Level_Type;
      Signal_Level : Signal_Level_Type;
      Name : SU.Unbounded_String;
      Last_Update : AC.Time;
      Used : boolean ;
      Successful_Initialisation : boolean := false;
      Temperature : Temp_Xten_Type;
      Protected_Device : boolean; 
   end record;

The stack trace passed through addr2line (etc) is different

/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:694 (discriminator 3)
/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:689
/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:342
/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:356 (discriminator 2)
/home/tony/Dropbox/source/common/data_feed_update_pkg.adb:73 (discriminator 2)
/home/tony/Dropbox/source/common/data_feed_update_pkg.adb:48
/home/tony/Dropbox/source/common/data_feed_update_pkg.adb:41
/home/tony/Dropbox/source/common/decision_maker_pkg.adb:29 (discriminator 2)
s-tassta.adb:?

which is this and is a procedural call inside a protected object

   procedure Set_Device (Device : in Device_Details_Type) is
        
      begin
         if Initialised then
            gnoga.log("Device id " & Device.Device_Id'img);
            Device_Array(Device.Device_Id) :=Device;   -- LINE 694 where the error is reported
            if Device.Device_Id > 0 then
               Device_File_Storage.Save_Record (File_Item => Device,
                                               To => Device.Device_Id);
            else
               Gnoga.log ("Zero Device Id Device Record  NOT SAVED TO DISK");
            end if;

         else
            Gnoga.Log("Devices not loaded from disk");
         end if;

        
      exception
         when E : others => Gnoga.log (Ada.Exceptions.Exception_Information (E));

      end Set_Device;


The array that is being written to is a fixed array. There is a value of Ada.Calendar.Time in the record but I cannot see why this would cause the problem

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

* Re: I've not seen this error before
  2015-04-01  8:42 I've not seen this error before tonyg
@ 2015-04-01 13:08 ` Simon Wright
  2015-04-01 13:18   ` tonyg
  2015-04-02  5:33   ` Randy Brukardt
  0 siblings, 2 replies; 6+ messages in thread
From: Simon Wright @ 2015-04-01 13:08 UTC (permalink / raw)


tonyg <tonythegair@gmail.com> writes:

> 2015-04-01 09:19:32.10 : Exception name: PROGRAM_ERROR
> Message: adjust/finalize raised PROGRAM_ERROR: device_type_pkg.ads:115 finalize/adjust raised exception
>
> the code is an ada specification
>
>  type Device_Details_Type is record
>       Device_Id : Device_Index_Type;
>       The_Device : Device_Class_Type;
>       Room_Id : Room_Id_Type;
>       The_Id : Domoticz_ID_Type;
>       Battery_Level : Battery_Level_Type;
>       Signal_Level : Signal_Level_Type;
>       Name : SU.Unbounded_String;
>       Last_Update : AC.Time;
>       Used : boolean ;
>       Successful_Initialisation : boolean := false;
>       Temperature : Temp_Xten_Type;
>       Protected_Device : boolean; 
>    end record;

>    procedure Set_Device (Device : in Device_Details_Type) is
>         
>       begin

>             Device_Array(Device.Device_Id) :=Device;   -- LINE 694 where the error is reported

> The array that is being written to is a fixed array. There is a value
> of Ada.Calendar.Time in the record but I cannot see why this would
> cause the problem

To get that exception you're going to have a controlled type somewhere,
very likely one of yours, and very likely to be found at
device_type_pkg.ads:115 (I'm guessing, some ancestor in the
Device_Class_Type tree? do you have some reason for naming this type
instead of just using Device'Class or (ugh) Device_Type'Class?).

At line 694 you are overwriting whatever was at
Device_Array(Device.Device_Id); full explanation of what this involves
starting at ARM 7.6(17).

Any unhandled exception raised in Initialize (?), Adjust (?) or Finalize
is going to be converted to PE. See ARM 7.6.1(14) ff.

You could always use the debugger and break on exceptions (e.g "catch
exception program_error").

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

* Re: I've not seen this error before
  2015-04-01 13:08 ` Simon Wright
@ 2015-04-01 13:18   ` tonyg
  2015-04-01 13:58     ` Niklas Holsti
  2015-04-02  5:33   ` Randy Brukardt
  1 sibling, 1 reply; 6+ messages in thread
From: tonyg @ 2015-04-01 13:18 UTC (permalink / raw)


I don't have any controlled types. I've never worked out how to use them :)

The only possibility I think is Ada.Calendar.Time which I think is a private type but not a controlled type.

Device_Class_Type is an enumerated type with three values.

This all seemed to happen when I started storing records in files.So I've now got a task which loads the file at the start then looks at a queue then sticks those changes back in the file.

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

* Re: I've not seen this error before
  2015-04-01 13:18   ` tonyg
@ 2015-04-01 13:58     ` Niklas Holsti
  2015-04-01 14:32       ` tonyg
  0 siblings, 1 reply; 6+ messages in thread
From: Niklas Holsti @ 2015-04-01 13:58 UTC (permalink / raw)


On 15-04-01 16:18 , tonyg wrote:
> I don't have any controlled types. I've never worked out how to use
> them :)

Your Device_Details_Type record has the component

    Name : SU.Unbounded_String;

Assuming "SU" is a renaming for Ada.Strings.Unbounded, then the record 
has a component of a type that needs finalization, namely 
Ada.Strings.Unbounded.Unbounded_String, and this type probably involves 
controlled types.

> This all seemed to happen when I started storing records in files.So
> I've now got a task which loads the file at the start then looks at a
> queue then sticks those changes back in the file.

Do you store also the Name component in the file? Directly as type 
Unbounded_String, or converted to some non-controlled type? An 
Unbounded_String almost certainly contain an access component to some 
heap-allocated text buffer. That access value is most likely no longer 
valid if you write it out from one run of the program and read it back 
in another run. Even if you read and write in the same run, the access 
value may have become invalid, because that heap block may have been 
released in between writing and reading.

It may help to change to Bounded_String (the ARM says these "should not" 
involve implicit pointers and dynamic allocation) but it would be safest 
to store the Name as a fixed-length String.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


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

* Re: I've not seen this error before
  2015-04-01 13:58     ` Niklas Holsti
@ 2015-04-01 14:32       ` tonyg
  0 siblings, 0 replies; 6+ messages in thread
From: tonyg @ 2015-04-01 14:32 UTC (permalink / raw)


Thanks Niklas, that explains it. 


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

* Re: I've not seen this error before
  2015-04-01 13:08 ` Simon Wright
  2015-04-01 13:18   ` tonyg
@ 2015-04-02  5:33   ` Randy Brukardt
  1 sibling, 0 replies; 6+ messages in thread
From: Randy Brukardt @ 2015-04-02  5:33 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lyk2xw0ze6.fsf@pushface.org...
...
> Any unhandled exception raised in Initialize (?), Adjust (?) or Finalize
> is going to be converted to PE. See ARM 7.6.1(14) ff.

Not Initialize; those just get propagated. Just Adjust and Finalize, which 
is why the message is "Adjust/Finalize".

                          Randy.


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

end of thread, other threads:[~2015-04-02  5:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-01  8:42 I've not seen this error before tonyg
2015-04-01 13:08 ` Simon Wright
2015-04-01 13:18   ` tonyg
2015-04-01 13:58     ` Niklas Holsti
2015-04-01 14:32       ` tonyg
2015-04-02  5:33   ` Randy Brukardt

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