comp.lang.ada
 help / color / mirror / Atom feed
From: "ldries46" <bertus.dries@planet.nl>
Subject: Garbage Collection ???
Date: Fri, 13 Apr 2012 14:14:43 +0200
Date: 2012-04-13T14:14:43+02:00	[thread overview]
Message-ID: <4f881910$0$2652$703f8584@news.kpn.nl> (raw)

I am creating a program within GNAT Programming Studio in which I have to 
create A List of the model

edges  :  ptr_Node;
where ptr_Node is
.....
.....
next : ptr_edge;
end record;

This structure is called throughout my program extensively with no problems 
but within a declare begin ... end
part of the form

declare
   stold_Points : ptr_Node;
   old_Points : ptr_Node;
begin
     stold_Points := new Node;
      ...
      ...
end;

This program part is run within a while loop.

Now the following occurs:

I get a segmentation fault on line 196 within the program lines:

            edges := stedges;
            while edges /= NULL loop
                Edge_Force(edges);
line 196   edges := edges.next;
            end loop;
with the fault message:

Program received signal SIGSEGV, Segmentation fault.
0x0054694c in falling.falling_ball (file_name=..., version=...) at 
E:\ada\project\Cell_3D\Source Files\Falling.adb:196

At the point the program is stopped I get the following values printed

(gdb) print stedges
$9 = (access general.edge) 0x3e2dbf8

(gdb) print edges
$8 = (access general.edge) 0x0

The fault is the result of the last result that is clear edges = NULL when 
edges.next is called
but as the code of Edge_Force is

procedure Edge_Force(edge1 : ptr_Edge) is
   len : float;
begin
   len := Length(edge1.P1.pnt, edge1.P2.pnt) - edge1.l_init;
   if abs(len / edge1.l_init) < 0.00001 then
     len := 0.0;
   end if;
   edge1.force := edge1.k_s * len;
end Edge_Force;

I don't change the value of edges so as I read it edges could not be NULL at 
that point.

What also causes the changed value of edges within the loop. Can it be some 
garbage problem.
At the moment the fault occurs the outer loop has run for at least serveral 
hundred times

L. Dries





             reply	other threads:[~2012-04-13 12:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13 12:14 ldries46 [this message]
2012-04-13 13:20 ` Garbage Collection ??? Dmitry A. Kazakov
2012-04-13 19:27   ` ldries46
2012-04-13 20:06     ` Dmitry A. Kazakov
2012-04-13 22:49     ` Brian Drummond
2012-04-14  3:21       ` ldries46
2012-04-14 18:21         ` Robert A Duff
2012-04-18  9:07           ` Julian Leyh
2012-04-19 14:36             ` Robert A Duff
2012-04-19 20:26               ` Randy Brukardt
2012-04-20  7:11                 ` Dmitry A. Kazakov
2012-04-21  0:46                   ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
1992-04-22 18:55 Garbage collection? dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!yale.edu!jvnc.net!darw
1992-04-21 23:48 Robert I. Eachus
1992-04-21 23:02 Rick Hudson
1992-04-21 21:09 titan.ksc.nasa.gov!mcroberts
replies disabled

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