Grupos de Google ya no admite nuevas publicaciones ni suscripciones de Usenet. El contenido anterior sigue siendo visible.

strange execution error

Visto 2 veces
Saltar al primer mensaje no leído

alfonso acosta

no leída,
22 feb 2003, 17:31:0822/2/03
a
Hi:

I recently started a project in savannah called adabot
(https://savannah.nongnu.org/projects/adabot/). Its a realtimebattle
(http://realtimebattle.sourceforge.net/) bot developed completely in Ada.

The problem I have, is the following:

When trying to test a package which isnt finished (messages.ads in
http://savannah.nongnu.org/cgi-bin/viewcvs/adabot/adabot/src/)
with this procedure:

-----
with Ada.Strings.Unbounded.Text_IO, Ada.Interrupts.Names ;
use Ada.Strings.Unbounded.Text_IO, Ada.Interrupts.Names, Ada.Interrupts;

procedure Messages.Test is

Msg : Msg_From_Robot;
Str : Unbounded_String;
begin

Msg := (RobotOption, (Signal, SIGUSR1));
Msg2Str (Msg, Str);
Put (Str);
end Messages.Test;
-----

After compiling with GNAT I execute it and it gets completely frozen,
the most curious about it is that 4 processes are created. Gdb tells me
the error comes from messages.adb line 152:


Append(Source => Str,
New_Item => Interrupt_ID'Pos(Msg.Value.Which));

but I dont understand why its wrong

Can anybody have a look at the code?

Thanks in advance:

Alfonso Acosta

PS: If anyone is interested in the project Ill be pleased to give
him/her a CVS write account (Its obvoius that Im not an experienced Ada
programmer and need some help)

Zheng Long Gen

no leída,
23 feb 2003, 10:49:0823/2/03
a comp.l...@ada.eu.org

>After compiling with GNAT I execute it and it gets completely frozen,
>the most curious about it is that 4 processes are created. Gdb tells me
>the error comes from messages.adb line 152:
>
>
> Append(Source => Str,
> New_Item => Interrupt_ID'Pos(Msg.Value.Which));

acturally the problem is caused by the first call to set_string in
messages.adb
Set_String (UP => Str, S => MFR_Arr(Msg.Cons);

this procedure set the contents of str an access value which points to a
library level aliased constant string. The procedure Append, however, will
free the memory of this constant string after allocate new space of memory.
Work around:
procedure To_unbounded_string will be more safer :
str:=to_unbounded_string(MFR_Arr(Msg.Cons).all);
By the way, the second local procedure append (...) which appends a float to
the unbounded string is also terrible:
............
P : String_Access := null;
begin
Put(P.all, New_Item);
I don't think a string_access object pointing to null can hold anything
legally.

Hope this will help

zhenggen
20030223

0 mensajes nuevos