From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10506 invoked by alias); 22 Nov 2009 17:02:35 -0000 Received: (qmail 7120 invoked by alias); 22 Nov 2009 17:02:21 -0000 Date: Sun, 22 Nov 2009 17:02:00 -0000 Message-ID: <20091122170221.7119.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug ada/42140] GNAT appears to misbehave with limited tagged types and possibly finalization In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "john at johnnowak dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-11/txt/msg01861.txt.bz2 ------- 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, > =4324888, > =0x0, > =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