From: xorque on
On Nov 22, 11:25 am, Georg Bauhaus <rm-
host.bauh...(a)maps.futureapps.de> wrote:
> >http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42140
>
> Do you get segmentation fault with GNAT run in Ada mode?
> (Currently, this would mean options -gnato -fstack-check
> and no -gnatp, I think.)

Yes, I actually always compile code with the following:

-O2 -g -fstack-check -gnatw.eHeFT -gnatVa -gnato -gnata
-gnatW8 -gnatiw -gnaty2aAbdefhiklnprStu

(Although without -O2 when actually writing code, though).

> What happens if you name the access-to-String type used for
> a component of Archive_t, i.e. something like

No change, unfortunately.

Regards,
xw
From: Dmitry A. Kazakov on
On Sun, 22 Nov 2009 12:25:40 +0100, Georg Bauhaus wrote:

> On 11/22/09 6:45 AM, xorque wrote:
>>
>> For this (minor) project, I tried a multitude of different approaches
>> and ended up
>> with one that appeared safe, right until it ended up causing GNAT to
>> have some
>> sort of heart attack:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42140
>
> Do you get segmentation fault with GNAT run in Ada mode?
> (Currently, this would mean options -gnato -fstack-check
> and no -gnatp, I think.)

The code is broken. It creates a temporal object and takes an access to its
component. The obtained pointer is dangling.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: xorque on
On Nov 22, 4:25 pm, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de>
wrote:
> The code is broken. It creates a temporal object and takes an access to its
> component. The obtained pointer is dangling.
>

Not sure which part of the code you're referring to here.

Regards,
xw
From: Dmitry A. Kazakov on
On Sun, 22 Nov 2009 08:27:59 -0800 (PST), xorque wrote:

> On Nov 22, 4:25�pm, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de>
> wrote:
>> The code is broken. It creates a temporal object and takes an access to its
>> component. The obtained pointer is dangling.
>
> Not sure which part of the code you're referring to here.

The function Open_Archive returns a new object. In Main you call it and
then apply the function Stream to the result. Stream returns an access to
the component File of the temporal object created by Open_Archive. Then
this object is destroyed and a dangling pointer is assigned to S. When you
call Integer'Inpit on S, it accesses a garbage.

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: xorque on
On Nov 22, 4:42 pm, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de>
wrote:
> On Sun, 22 Nov 2009 08:27:59 -0800 (PST), xorque wrote:
> > Not sure which part of the code you're referring to here.
>
> The function Open_Archive returns a new object. In Main you call it and
> then apply the function Stream to the result. Stream returns an access to
> the component File of the temporal object created by Open_Archive. Then
> this object is destroyed and a dangling pointer is assigned to S. When you
> call Integer'Inpit on S, it accesses a garbage.

Ah, I see what you mean.

In the process of trying to save the result of Open_Archive so that I
can test
if this problem still occurs, I've run into another problem:

A : Archiver.Archiver_t;
O : constant Archiver.Archive_t := Archiver.Archive_t
(Archiver.Open_Archive (A, "file.zip"));
S : constant Stream_IO.Stream_Access := Archiver.Stream (O);

main.adb:9:46: illegal context for call to function with limited
result

I have to admit to not understanding that error.