TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Simon Wright <[log in to unmask]>
Reply To:
Simon Wright <[log in to unmask]>
Date:
Wed, 12 May 1999 21:09:10 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (52 lines)
> From: "Martin C. Carlisle" <[log in to unmask]>
> X-To:         "\"\\\\\"\\\\'[\\\\\"[log in to unmask]\\\\\"
>               <[log in to unmask]>'\\\\
>               Servers[\\\\[log in to unmask]\\\\\\\"\\\" ]"
>               <[log in to unmask]>
>
> I've done some experiments on this.  This is the behavior I detect on GNAT
> 3.11p (Windows 98).
>
> If I initialize both the Unbounded_String(s) to Null_Unbounded_String and
> explicitly override Swap in Car with the exact same code, then it works
> fine.
>
> Perhaps someone else can enlighten as to why this behavior occurs (may be a
> bug?-- consider sending to [log in to unmask]).  I added a dummy e1 package
> below.

On Linux, with 3.11p i486-pc-linux-gnulibc1 I get

  pogner[21]$ e1-main

  raised PROGRAM_ERROR : stack overflow (or erroneous memory access)

The debugger says we've stopped at

  Program received signal SIGSEGV, Segmentation fault.
  0x805668a in ada__tags__get_prim_op_address ()
  Current language:  auto; currently c
  (gdb) bt
  #0  0x805668a in ada__tags__get_prim_op_address ()
  #1  0x8057f11 in system__finalization_implementation__finalize_list ()
  #2  0x8049c60 in <e1__vehicle__swap___clean> () at e1-vehicle.adb:3
  #3  0x804a161 in e1.vehicle.swap (l=@0xbffff5f0, r=@0xbffff42c)
      at e1-vehicle.adb:9
  ...
  (gdb) fr 3
  #3  0x804a161 in e1.vehicle.swap (l=@0xbffff5f0, r=@0xbffff42c)
      at e1-vehicle.adb:9
  9             R := Temp;

I think the trouble is that Swap is only handling the Vehicle.Object
view and not the full Car.Object view. I don't know if this is a bug
or not. You can certainly avoid the crash by providing Car.Swap (with
the same implementation).

You can also win by making Vehicle.Swap take classwide parameters

   procedure Swap (L,R : in out Object'Class);

in which case you might want to add a check in the body that both
parameters are of the same actual class.

ATOM RSS1 RSS2