SRL Archive - SRL Bugs

DTM Failure in AntiRandoms.scar and Simba Fail


3Garrett3

2010-05-16 14:07:21

Hello,

I really do not wish to create a bug tracking account or whatever it is, I will just make a post here.

Recently, while trying to work on msi, I became aware of a failure in both SRL and Simba. First, I will mention the failure of Simba. What I wish to bring to the attention of developers is the poor error reports. It gave the wrong location, as well as an error which is impossible to follow up.

[PHP]Error: Exception: The given DTM Index[0] doesn't exist at line 352[/PHP]

The client then opened up "Antirandoms.scar" and highlighted line 352. Looking at the line (Opendev revision) you may be confused, as you should be. The line is blank. Prior is "Function FindFight : Boolean" and after is "begin". But this could not be the error which is causing the crash, so I looked through the FindFight function and the function preceding it. Neither even contained a DTM finding/freeing function.

So I asked my friend Cohen to open up SCAR, and run msi. When he got the error, he got the report:

[PHP][Runtime Error] : Exception: Access violation at address 007876D4 in module 'scar.exe'. Read of address 00000000 in line 383 in script Z:\home\cohen\SCAR\includes\SRL\SRL\Core\AntiRandoms\AntiRandoms.scar[/PHP]

Looking at the include, the code is:


GameTab(tab_Inv);
if not SRLBitmapsLoaded then
LoadSRLBitMaps;
if (FindDTM(Lamp, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
Result := True;

Where line 383 is the FindDTM(Lamp) line.

So, I have no idea why this causes a crash, but the only thing I can think of is that the DTMs aren't loading like they should, causing a crash.

If someone could clear this up and update the rev, I would greatly appreciate it. As well, if someone could look into why Simba reported the wrong line/area for the failure, that would be appreciated. The error reports in Simba require a large overhaul IMO, because the ones in SCAR actually tell you what went wrong, where the Simba ones are confusing and don't actually help.

Thanks for your patience,
Garrett

Frement

2010-05-16 14:12:04

I have also had some problems Simba outputting "These bitmaps have not been freed: SRL_Lamp" or something. And there was some other too.

3Garrett3

2010-05-16 14:16:36

From: Frement
I have also had some problems Simba outputting "These bitmaps have not been freed: SRL_Lamp" or something. And there was some other too.


Seems something in the Antirands went wrong.

PS- To any staffers, I probably shouldn't have tagged this "Confirmed" but myself and Cohen both have the newest SRL and msi and have the same problem, so I considered it confirmed.

nielsie95

2010-05-16 14:25:52

Those bitmaps are up to the user to be freed (FreeSRLBitmaps) at the end of the script. Garret, I can't seem to reproduce your bug:


program new;
{.include SRL/SRL.scar}

begin
SetupSRL;
FindLamp('test');
end.

should crash according to you? Are you sure this is not an MSI bug?

3Garrett3

2010-05-16 14:34:20

From: nielsie95
Those bitmaps are up to the user to be freed (FreeSRLBitmaps) at the end of the script. Garret, I can't seem to reproduce your bug:


program new;
{.include SRL/SRL.scar}

begin
SetupSRL;
FindLamp('test');
end.

should crash according to you? Are you sure this is not an MSI bug?


At first I thought the same thing as you, but when looking at the reports of SCAR and Simba, it seems highly unlikely that MSI is causing a crash but reporting it as a fault in Antirandoms.

I will look through MSI, but if it becomes a case of MSI causing the crash, I would wish for a Simba Dev to take a hard look at the error reporter, because it just doesn't make sense that it is reported in the way that it is.

nielsie95

2010-05-16 14:52:31

I've did a quick search through SRL and MSI, but I can't find anything that changed the Lamp variable, so the only thing I can come up with is that it is not loading properly. What script did you run? RunMe.scar from MSI?

Coh3n

2010-05-16 15:13:56

From: nielsie95
I've did a quick search through SRL and MSI, but I can't find anything that changed the Lamp variable, so the only thing I can come up with is that it is not loading properly. What script did you run? RunMe.scar from MSI?

Yes. I had almost exactly the same problem a while back (except I was getting a "DTM is not consistant" error. See this thread for more details). The same line in AntiRandoms would get highlighted (the blank on in Simba), but it was eventually fixed when I discovered that the loading and freeing of the msi items was in the wrong place in Banking.scar.

I'm been looking at MSI/SRL for the last 20 minutes and I cannot figure out what would cause this. Recently, DDTMs were added to MSI to replace the DTMs for items such as hatchets/logs/ores. Right now, only hatchets and logs have been added in this system. I'm guessing this problem arose once again when the DDTM system was committed.

However, I don't think that's the problem because I'm running MSI as a powerchopper right now and it's working perfectly, so I don't think there's any problem when the loading/freeing of the DDTMs.

Wizzup?

2010-05-16 15:46:20

From: 3Garrett3

[PHP]Error: Exception: The given DTM Index[0] doesn't exist at line 352[/PHP]

[PHP][Runtime Error] : Exception: Access violation at address 007876D4 in module 'scar.exe'. Read of address 00000000 in line 383 in script Z:\home\cohen\SCAR\includes\SRL\SRL\Core\AntiRandoms\AntiRandoms.scar[/PHP]

Looking at the include, the code is:

If someone could clear this up and update the rev, I would greatly appreciate it. As well, if someone could look into why Simba reported the wrong line/area for the failure, that would be appreciated. The error reports in Simba require a large overhaul IMO, because the ones in SCAR actually tell you what went wrong, where the Simba ones are confusing and don't actually help.

Thanks for your patience,
Garrett


Ehm, do you find
Exception: Access violation at address 007876D4 in module 'scar.exe'. Read of address 00000000 in line 383 in script Z:homecohenSCARincludesSRLSRLCoreAntiRandomsAntiRandoms.scar
a better error than
Error: Exception: The given DTM Index[0] doesn't exist at line 352
?

In this case, Simba tells you exactly what is wrong. The DTM is not loaded correctly somehow. (Either an error in the script or in Simba, but I'm pretty sure it is an error in the script, seeing that it stops SCAR too)
SCAR however, doesn't tell you anything. I can't grasp how you find the Simba errors not informative… :cartman:

Back on topic… Try finding out what revision causes this bug?

From: Frement
I have also had some problems Simba outputting "These bitmaps have not been freed: SRL_Lamp" or something. And there was some other too.


Ehm… Simba tells you those bitmaps weren't freed by SRL, and then frees them itself. SCAR however, does not tell you this, nor does it free the bitmaps SRL has not freed. :)

Wanted

2010-05-16 15:48:13

{.include SRL\SRL.scar}

procedure ScriptTerminate;
begin
SRLFreeBitmaps;
end;

begin
SetUpSRL;
FindNormalRandoms;
end.

This is not a problem with SRL.

Coh3n

2010-05-16 15:48:22

From: Wizzup?

Back on topic… Try finding out what revision causes this bug?

That's actually a really good idea. :D I'm going to check that out now.

<3

Frement

2010-05-16 15:49:55

From: Wizzup?
Ehm… Simba tells you those bitmaps weren't freed by SRL, and then frees them itself. SCAR however, does not tell you this, nor does it free the bitmaps SRL has not freed. :)


Yeah I know :) Thats why Simba > SCAR.

Wizzup?

2010-05-16 15:51:01

From: Frement
Yeah I know :) Thats why Simba > SCAR.


Correction: Raymond just told me that SCAR does free the bitmaps, it just doesn't tell you about it.

3Garrett3

2010-05-16 16:14:17

From: Wizzup?
Ehm, do you find
Exception: Access violation at address 007876D4 in module 'scar.exe'. Read of address 00000000 in line 383 in script Z:homecohenSCARincludesSRLSRLCoreAntiRandomsAntiRandoms.scar
a better error than
Error: Exception: The given DTM Index[0] doesn't exist at line 352
?

In this case, Simba tells you exactly what is wrong. The DTM is not loaded correctly somehow. (Either an error in the script or in Simba, but I'm pretty sure it is an error in the script, seeing that it stops SCAR too)
SCAR however, doesn't tell you anything. I can't grasp how you find the Simba errors not informative… :cartman:

Back on topic… Try finding out what revision causes this bug?



Ehm… Simba tells you those bitmaps weren't freed by SRL, and then frees them itself. SCAR however, does not tell you this, nor does it free the bitmaps SRL has not freed. :)


Well, to look at it from a purely informational basis with the report, you could argue that Simba was correct. It told me that the DTM did not exist on line 352 of antirandoms.scar. This is true. However, when looking from a "bug fixing" point of view, the report has no value of help at all, because it points to a blank line of something that wasn't even called.

The SCAR report doesn't say why, of course, and does not mention DTM freeing of any sort. But, it does direct to something that would make sense; a line containing a DTM finding function. It also tells us definitively that the error was contained in the Antirandoms.scar file, which I had purposely updated this morning from the opendev revision.

In reality, neither report was 100% helpful. The combination of both was what lead me to the information. What I'm saying is that without SCAR's debugging, we would have no way of knowing what went wrong, because the line reported as causing the flaw was erroneous in Simba's reporting system.

This was all on topic, as my original report contained two bugs, the reporting system, and the apparent "bug" which is only replicated through MSI, but appears in SRL for some reason.

Coh3n

2010-05-16 16:30:28

I found the problem, although I have absolutely not idea why it was causing an error. In the following function, an array of MSI items is loaded, then the items are deposited into the bank, then the items are freed regardless of whether they were actually deposited or not.

Function MSI_Deposit(Items, Amount: TIntegerArray) : Boolean;
Var ATPA2 : Array Of TPointArray; //The length is the same as items.colors
ATPA : T2DPointArray;
I, BX, BY, II, DX, DY, XX, YY, Tol : Integer;
BitmapCheck, TextCheck, DTMCheck : Boolean;
TB : TBox;

Begin
if (not LoggedIn) then
Exit;

if (Length(Amount) <= 0) then
begin
SetLength(Amount, Length(Items));
for i := 0 to High(Amount) do
Amount[i] := 28;
end;

If Not WaitFunc(@BankScreen, 70, 1300) Then //Just in case
Exit
Else begin
MSI_LoadItems(Items);
For I := 0 To High(Items) Do
Begin
Tol := 0;
Repeat
BitmapCheck := FindBitmapToleranceIn(MSI_Item[Items[I]].BMP, BX, BY, MIX1, MIY1, MIX2, MIY2, Tol);
IncEx(Tol, INC_TOL);
Until(BitmapCheck) Or (Tol >= MAX_TOL);

If Not BitmapCheck Then
Begin
SetArrayLength(ATPA2, High(MSI_Item[Items[I]].Colors)+1)

For II := 0 To High(MSI_Item[Items[I]].Colors) Do
FindColorsTolerance(ATPA2[II], MSI_Item[Items[I]].Colors[II], MIX1, MIY1, MIX2, MIY2, 15);

ATPA2[0] := MergeATPA(ATPA2);
ATPA := SplitTPA(ATPA2[0], 5);

For II := 0 To High(ATPA) Do
Begin
TB := IntToBox(ATPA[II][0].x - 50, ATPA[II][0].y - 50,
ATPA[II][0].x + 43, ATPA[II][0].y + 44);

DTMCheck := DTMRotated(MSI_Item[Items[I]].DTM, DX, DY, TB.x1, TB.y1, TB.x2, TB.y2);
MMouse(DX, DY, 2, 3);
TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 150+Random(30));
If TextCheck Then Break;
End;
End;

If BitmapCheck Or TextCheck Then
Begin
If BX + BY > 0 Then
MMouse(BX, BY, 2, 3);

TextCheck := WaitUpTextMulti(MSI_Item[Items[I]].UpText, 1200);
GetMousePos(XX, YY);
Result := TextCheck;

If Result Then
Begin
Mouse(XX, YY, 0, 0, False);

If Amount[I] >= 28 Then
Result := WaitOption('-All', 1200);

If InIntArray([1, 5, 10], Amount[I]) Then
Result := WaitOption('-'+IntToStr(Amount[I]), 1200)
Else
Begin
If WaitOption('-X', 900) Then
If WaitColor(254, 401, ClBlack, 0, 1200) Then
TypeSend(IntToStr(Amount[I]));

Result := True;
End;

If Result Then
MSI_Debug('MSI_Deposit', 'Deposited Amount '+IntToStr(Amount[I])+
' Of Item : ''' +MSI_Item[Items[I]].Name+'''', DEBUG_SMALL_DETAILS);
End;
End;
End;

MSI_FreeItemArray(Items); //if you comment out this line, the error no longer occurs.
end;
End;
Notice the comment on the MSI_FreeItemArray line. Since the item was loaded, deposited and the function returned true, I don't see why there would be an error.

The script even moves on. It starts walking back to the location THEN the DTM error occurs.

Wanted

2010-05-16 16:55:50

My guess is MSI is improperly freeing a DTM, which is probably not loaded making it "0" which is the same as the LampDTM (the first loaded is 0) then when you go to use FindLamp the lamp dtm is not loaded because MSI freed it.

Coh3n

2010-05-16 16:58:54

From: IceFire908
My guess is MSI is improperly freeing a DTM, which is probably not loaded making it "0" which is the same as the LampDTM (the first loaded is 0) then when you go to use FindLamp the lamp dtm is not loaded because MSI freed it.

That seems logical. I'm testing a a fix now. It should get rid of all the problems plus slightly improve efficiency.