SRL Archive - Lape

??


Olly

2014-10-10 19:14:20

This has to be some record for the most messed up bug ever;

@nielsie95

var
TBA: array of TBoxArray;
Res: TBoxArray;
begin
SetLength(TBA, 3);

TBA[0] := [[68, 84,116, 125], [117, 84, 165, 125], [166, 84, 214, 125], [215, 84, 263, 125], [264, 84, 310, 125]];
TBA[1] := [[48, 149, 99, 196], [100, 149, 151, 196], [152, 149, 203, 196], [204, 149, 255, 196], [256, 149, 307, 196], [308, 149, 309, 196]];
TBA[2] := [[25, 225, 81, 279], [82, 225, 138, 279], [139, 225, 195, 279], [196, 225, 252, 279], [253, 225, 307, 279]] ;

Res := [TBA[0][0],TBA[0][1],TBA[0][2],TBA[0][3],TBA[0][4],TBA[1][0],TBA[1][1],TBA[1][2],TBA[1][3],TBA[1][4],TBA[2][0],TBA[2][1],TBA[2][2],TBA[2][3],TBA[2][4]];

Writeln('I''m some messed up array ', High(Res));
Writeln('Let''s do what we just did.... exactly... again.');

Res := [TBA[0][0],TBA[0][1],TBA[0][2],TBA[0][3],TBA[0][4],TBA[1][0],TBA[1][1],TBA[1][2],TBA[1][3],TBA[1][4],TBA[2][0],TBA[2][1],TBA[2][2],TBA[2][3],TBA[2][4]];

Writeln('I''m... fine? ', High(Res));
end.

Compiled successfully in 312 ms.
I'm some messed up array 280
Let's do what we just did.... exactly... again.
I'm... fine? 14

e: If i set it like this, it works fine.

for i := 0 to 2 do
for j := 0 to 4 do
begin
SetLength(Res, Length(Res) + 1);
Res[High(Res)] := TBA[i][j];
end;

:confused:

Ashaman88

2014-10-10 23:48:54

Lape don't like your arrays!!

Gu3st...

2014-10-12 16:28:32

var
ATIA : array of TIntegerArray;
Res: TIntegerArray;
begin
setLength(ATIA, 2);

ATIA[0] := [1];
ATIA[1] := [2];

//ATIA[0][0];

Res := [ATIA[0][0], ATIA[1][0], ATIA[1][0]];
writeLn(Res);

Res := [ATIA[0][0], ATIA[1][0], ATIA[1][0]];
writeLn(Res);
end.
Not only TBoxArray :/

Compiled successfully in 312 ms.
[2, 2]
[1, 50, 50]
Successfully executed.

E: Err, calling one member of the array before setting Res resolves the problem (The commented out line)

slacky

2014-10-12 22:32:11

By using an alias for TIntegerArray, or just typing it as an "open array" will result in it being handled correctly:

type
TIntArray = TIntegerArray;

var
ATIA : Array of TIntegerArray;
Arr: TIntArray; //an alias is enough to fix it which is VERY weird.
begin
SetLength(ATIA, 2);
ATIA[0] := [1];
ATIA[1] := [2];

WriteLn('Should yield same res:');
Arr := [ATIA[0][0], ATIA[1][0], ATIA[1][0]];
WriteLn(Arr,' | Len: ', length(Arr));

Arr := [ATIA[0][0], ATIA[1][0], ATIA[1][0]];
WriteLn(Arr,' | Len: ', length(Arr));
end.

Issue seems to be part of the lptree.pas line 1100. I reverted that line, got it working, but recreated some old bug -> this one. So the issue did not exist in older Lape, but came with the previously array-initialization bugfix.

Extending on the issues with array initialization, I noted some time ago (very old issue) that this will cause lape to access violate, which then crashes the Lape-thread:

var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([1]); //<-- explicit cast.
end.
>> Error: Access violation at line 5
>> Execution failed.
>> Exception TLPThread.Destroy: Access violation

Brandon

2014-10-13 11:51:54

From: slacky
Cause lape to access violate..




var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([0]); //does not crash.
writeln(Arr[0]);
end.


var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([0, 1]); //does not crash.
writeln(Arr[0]);
end.


var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([1]); //Crashes.
writeln(Arr[0]);
end.

I dunno.. weird.

masterBB

2014-10-13 12:39:23

From: Brandon

var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([0]); //does not crash.
writeln(Arr[0]);
end.


var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([0, 1]); //does not crash.
writeln(Arr[0]);
end.


var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := TIntegerArray([1]); //Crashes.
writeln(Arr[0]);
end.

I dunno.. weird.


var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := [0]; //Does not crash.
writeln(Arr[0]);
end.

slacky

2014-10-13 13:12:07

From: masterBB
var
Arr: Array of TIntegerArray;
begin
SetLength(Arr, 1);
Arr[0] := [0]; //Does not crash.
writeln(Arr[0]);
end.

Yeah, I kinda mentioned that it had to be explicitly cast (in the code comment).

Dgby714

2014-11-28 15:51:47

@nielsie95;, Olly is to lazy to make a issue on googlecode, making sure you see this.