comp.lang.ada
 help / color / mirror / Atom feed
* Help: program won't ends (GNAT)
@ 2007-01-21 23:17 Yves Bailly
  2007-01-22  8:14 ` Niklas Holsti
  2007-01-22  9:51 ` Brian May
  0 siblings, 2 replies; 7+ messages in thread
From: Yves Bailly @ 2007-01-21 23:17 UTC (permalink / raw)


Hello all,

I'm a bit confused by the following behaviour. Please consider this simple
program (a much larger one reduced to its minimum):

---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure Bug is

   type A_1 is array(1..1) of Unbounded_String;
   type A_2 is array(1..1) of A_1;

   type Rec is
   record
      f: A_2 := (others => (others => Null_Unbounded_String));
   end record;
   
   var: Rec;
begin
   Put_Line("START");
   Put_Line("END");
end Bug;
---8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<--

When I run the program, both strings are displayed, but the program doesn't
exit: it just keeps running, eating 75% of my CPU power.
Playing a little bit with a debugger (I'm an absolute newbe with gnat_gdb),
it seems I'm looping into a "bug__clean" function, more precisely somewhere
in "system__finalization_implementation__finalize_list" or
"system__finalization_implementation__finalize".

Compiled by GNAT-2006 (the latest release) or by the GNAT provided with
GCC 4.1, both give the same behaviour.

If I change the "A_2" in the record for "A_1", then everything works fine.
If I remove the aggregate to initialize the "f" component, then everything
works fine.

What's wrong with my code ? Is it a GNAT bug ?

Any hint or workaround would be much appreciated.

Regards,

-- 
(o< | Yves Bailly  : http://kafka-fr.net   | -o)
//\ | Linux Dijon  : http://www.coagul.org | //\
\_/ |                                      | \_/`



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: program won't ends (GNAT)
  2007-01-21 23:17 Help: program won't ends (GNAT) Yves Bailly
@ 2007-01-22  8:14 ` Niklas Holsti
  2007-01-22 10:54   ` Georg Bauhaus
  2007-01-22 19:25   ` Yves Bailly
  2007-01-22  9:51 ` Brian May
  1 sibling, 2 replies; 7+ messages in thread
From: Niklas Holsti @ 2007-01-22  8:14 UTC (permalink / raw)


Yves Bailly wrote:
> Hello all,
> 
> I'm a bit confused by the following behaviour. Please consider this simple
> program (a much larger one reduced to its minimum):
    [snip]
> When I run the program, both strings are displayed, but the program doesn't
> exit: it just keeps running, eating 75% of my CPU power
    [snip]
> Compiled by GNAT-2006 (the latest release) or by the GNAT provided with
> GCC 4.1, both give the same behaviour.

I observe the same behaviour on gnat 3.15p, Debian Linux. Seems to be a 
GNAT bug of respectable age.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: program won't ends (GNAT)
  2007-01-21 23:17 Help: program won't ends (GNAT) Yves Bailly
  2007-01-22  8:14 ` Niklas Holsti
@ 2007-01-22  9:51 ` Brian May
  1 sibling, 0 replies; 7+ messages in thread
From: Brian May @ 2007-01-22  9:51 UTC (permalink / raw)


>>>>> "Yves" == Yves Bailly <kafka.fr@laposte.net> writes:

    Yves>    type Rec is record f: A_2 := (others => (others =>
    Yves> Null_Unbounded_String)); end record;
   
If I replace this with:

type Rec is record f: A_2 := (1 => (others => Null_Unbounded_String)); end record;

Then it works with gcc-4.1

So, at quick glance, it looks like a bug with the "others" keyword to
me.

Changing the 2nd others had no effect.
-- 
Brian May <bam@snoopy.apana.org.au>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: program won't ends (GNAT)
  2007-01-22  8:14 ` Niklas Holsti
@ 2007-01-22 10:54   ` Georg Bauhaus
  2007-01-22 19:25   ` Yves Bailly
  1 sibling, 0 replies; 7+ messages in thread
From: Georg Bauhaus @ 2007-01-22 10:54 UTC (permalink / raw)


On Mon, 2007-01-22 at 10:14 +0200, Niklas Holsti wrote:
> Yves Bailly wrote:

> > When I run the program, both strings are displayed, but the program doesn't
> > exit: it just keeps running, eating 75% of my CPU power
>   ...
> I observe the same behaviour on gnat 3.15p, Debian Linux. Seems to be a 
> GNAT bug of respectable age.
> 

It seems there is a circle in the pointers used
for unbounded string in this case.
Finalization jumps back and forth between

 Ada.Strings.Unbounded.Finalize  (Object : in out Unbounded_String) 
and
 System.Finalization_Implementation.Finalize_List (L : Finalizable_Ptr)

where object.reference = Null_String'Access
  and object.next = L -- same address!?

But Ada.Strings.Unbounded.Finalize does nothing, probably because:
--  Note: Don't try to free statically allocated null string

There is a loop in Finalize_List which intending to step
along the list in L and call Finalize on each pointer.
But this pointer stays the same.

Can any GNAT expert have a look, please?





^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: program won't ends (GNAT)
  2007-01-22  8:14 ` Niklas Holsti
  2007-01-22 10:54   ` Georg Bauhaus
@ 2007-01-22 19:25   ` Yves Bailly
  2007-01-23 19:05     ` Björn Persson
  1 sibling, 1 reply; 7+ messages in thread
From: Yves Bailly @ 2007-01-22 19:25 UTC (permalink / raw)


Niklas Holsti wrote:

> Yves Bailly wrote:
>> Hello all,
>> 
>> I'm a bit confused by the following behaviour. Please consider this
>> simple program (a much larger one reduced to its minimum):
>     [snip]
>> When I run the program, both strings are displayed, but the program
>> doesn't exit: it just keeps running, eating 75% of my CPU power
>     [snip]
>> Compiled by GNAT-2006 (the latest release) or by the GNAT provided with
>> GCC 4.1, both give the same behaviour.
> 
> I observe the same behaviour on gnat 3.15p, Debian Linux. Seems to be a
> GNAT bug of respectable age.
> 

Interestingly, if you move the initialization into the procedure's body:

[...]
   type Rec is
   record
      f: A_2;
   end record;
   var: Rec;
begin
   var.f := (others => (others => Null_Unbounded_String));
[...]

...then it works. Reading other posts, it definitely looks like a bug
in the compiler. Thanks to all for your answers.

Regards,

-- 
(o< | Yves Bailly  : http://kafka-fr.net   | -o)
//\ | Linux Dijon  : http://www.coagul.org | //\
\_/ |                                      | \_/`



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: program won't ends (GNAT)
  2007-01-22 19:25   ` Yves Bailly
@ 2007-01-23 19:05     ` Björn Persson
  2007-01-25  0:44       ` Jeffrey Creem
  0 siblings, 1 reply; 7+ messages in thread
From: Björn Persson @ 2007-01-23 19:05 UTC (permalink / raw)


Yves Bailly wrote:

> Reading other posts, it definitely looks like a bug
> in the compiler. Thanks to all for your answers.

You will report it in GCC's Bugzilla, won't you?

-- 
Bj�rn Persson                              PGP key A88682FD
                   omb jor ers @sv ge.
                   r o.b n.p son eri nu



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Help: program won't ends (GNAT)
  2007-01-23 19:05     ` Björn Persson
@ 2007-01-25  0:44       ` Jeffrey Creem
  0 siblings, 0 replies; 7+ messages in thread
From: Jeffrey Creem @ 2007-01-25  0:44 UTC (permalink / raw)


Bj�rn Persson wrote:
> Yves Bailly wrote:
> 
>> Reading other posts, it definitely looks like a bug
>> in the compiler. Thanks to all for your answers.
> 
> You will report it in GCC's Bugzilla, won't you?
> 

I was going to post the same thing on the group here but checked 
Bugzilla first and the bug had already been submitted.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-01-25  0:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-21 23:17 Help: program won't ends (GNAT) Yves Bailly
2007-01-22  8:14 ` Niklas Holsti
2007-01-22 10:54   ` Georg Bauhaus
2007-01-22 19:25   ` Yves Bailly
2007-01-23 19:05     ` Björn Persson
2007-01-25  0:44       ` Jeffrey Creem
2007-01-22  9:51 ` Brian May

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