This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ada/42140] GNAT appears to misbehave with limited tagged types and possibly finalization
- From: "john at johnnowak dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Nov 2009 17:02:21 -0000
- Subject: [Bug ada/42140] GNAT appears to misbehave with limited tagged types and possibly finalization
- References: <bug-42140-17358@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from john at johnnowak dot com 2009-11-22 17:02 -------
Subject: Re: GNAT appears to misbehave with limited tagged types and possibly
finalization
You know, your code would be a lot better if you didn't use anonymous
access types. (:-))
On Nov 22, 2009, at 11:41 AM, gcc at coreland dot ath dot cx wrote:
>
>
> ------- Comment #2 from gcc at coreland dot ath dot cx 2009-11-22
> 16:41 -------
> A couple of people have commented on the anonymous access type
> (claiming it causes the crash). Here's a version with it removed
> and a gdb backtrace:
>
> Program received signal SIGSEGV, Segmentation fault.
> system.finalization_implementation.move_final_list
> (from=0x800a02040, to=0x0)
> at s-finimp.adb:486
> 486 s-finimp.adb: No such file or directory.
> in s-finimp.adb
> (gdb) bt
> #0 system.finalization_implementation.move_final_list
> (from=0x800a02040,
> to=0x0) at s-finimp.adb:486
> #1 0x0000000000402cfb in archiver.open_archive (archiver=(),
> path=0x41fe18,
> <open_archiveBIPalloc>=4324888,
> <open_archiveBIPfinallist>=0x0,
> <open_archiveBIPaccess>=0x7fffffffe6d8) at
> archiver.adb:9
> #2 0x0000000000402e9f in main () at main.adb:9
>
> Probably advisable to add an assertion in Move_Final_List
> to ensure that 'To' is not null.
>
> -- %< archiver.ads
>
> with Ada.Finalization;
> with Ada.Streams.Stream_IO;
>
> package Archiver is
>
> type Archiver_t is tagged limited private;
> type Archive_t is tagged limited private;
>
> function Open_Archive
> (Archiver : in Archiver_t;
> Path : in String) return Archive_t'Class;
>
> function Stream
> (Archive : in Archive_t)
> return Ada.Streams.Stream_IO.Stream_Access;
>
> private
> package Stream_IO renames Ada.Streams.Stream_IO;
>
> type Archiver_t is tagged limited null record;
>
> type Archive_t is new Ada.Finalization.Limited_Controlled with record
> File : Stream_IO.File_Type;
> end record;
>
> end Archiver;
>
> -- %< archiver.adb
>
> package body Archiver is
>
> function Open_Archive
> (Archiver : in Archiver_t;
> Path : in String) return Archive_t'Class
> is
> pragma Unreferenced (Archiver);
> begin
> return A : Archive_t'Class :=
> Archive_t'(Ada.Finalization.Limited_Controlled with others => <>) do
> Stream_IO.Open
> (Name => Path,
> File => A.File,
> Mode => Stream_IO.In_File);
> end return;
> end Open_Archive;
>
> function Stream
> (Archive : in Archive_t)
> return Ada.Streams.Stream_IO.Stream_Access is
> begin
> return Stream_IO.Stream (Archive.File);
> end Stream;
>
> end Archiver;
>
> -- %< main.adb
>
> with Ada.Text_IO;
> with Ada.Streams.Stream_IO;
> with Archiver;
>
> procedure Main is
>
> A : Archiver.Archiver_t;
> S : constant Ada.Streams.Stream_IO.Stream_Access := Archiver.Stream
> (Archiver.Open_Archive (A, "file.zip"));
> X : Integer;
>
> begin
> X := Integer'Input (S);
>
> Ada.Text_IO.Put_Line (Integer'Image (X));
> end Main;
>
>
> --
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42140
>
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42140