Page 1 of 2
[FIXED] Retrieving something from an Array crash on Linux
Posted: Wed Apr 28, 2021 10:54 am
by Ats
I made a very simple test.
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression>
<Expression>
<![CDATA[//
Names[0]="MOON";
Names[1]="PLANET";
trace(Names[0]);]]>
</Expression>
</ZExpression>
</OnLoaded>
<Content>
<Array Name="Names" Type="2" SizeDim1="2"/>
</Content>
</ZApplication>
On Windows, "trace(Names[0]);" returns MOON.
But on Linux, it crashes:
An unhandled exception occurred at $00000000004018E7:
EAccessViolation: Access violation
$00000000004018E7
Re: Retrieving something from an Array crash on Linux
Posted: Wed Apr 28, 2021 11:00 am
by Ats
It works with array full of int, but not with arrays full of strings:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression>
<Expression>
<![CDATA[//
Numbers[0]= 0;
Numbers[1]= 1;
Names[0]="MOON";
Names[1]="PLANET";
trace(intToStr(Numbers[0]));
trace(Names[0]);]]>
</Expression>
</ZExpression>
</OnLoaded>
<Content>
<Array Name="Numbers" Type="1" SizeDim1="2"/>
<Array Name="Names" Type="2" SizeDim1="2"/>
</Content>
</ZApplication>
Re: Retrieving something from an Array crash on Linux
Posted: Wed Apr 28, 2021 1:00 pm
by VilleK
That is very strange. I don't have an explanation for this yet.
It could be something 64-bit specific but your example is working fine here on 64-bit windows.
Re: Retrieving something from an Array crash on Linux
Posted: Wed Apr 28, 2021 8:22 pm
by Ats
Array of float, byte and vec works too.
But array of model crashes.
I didn't try xptr and mat4.
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 7:40 am
by VilleK
Ats wrote: ↑Wed Apr 28, 2021 8:22 pm
But array of model crashes.
How did you test this exactly?
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 9:09 am
by Ats
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression>
<Expression>
<![CDATA[//
ArrayFloat[0]= 0.123;
ArrayFloat[1]= 0.456;
ArrayInt[0]= 0;
ArrayInt[1]= 1;
ArrayString[0]="MOON";
ArrayString[1]="PLANET";
for (int i=0; i<2; i++)
{
model m = createModel(Model);
m.ModelNumber = i;
ArrayModel[i] = m;
}
ArrayByte[0]= 0;
ArrayByte[1]= 1;
ArrayVec[0]= vector2(1,2);
ArrayVec[1]= vector2(3,4);
//trace(intToStr(ArrayInt[0])); // ok
//trace(intToStr(ArrayFloat[0]*1000)); // ok
//trace(ArrayString[0]); // crash
//trace(intToStr(ArrayModel[0].ModelNumber)); // crash
model m = ArrayModel[0]; // ok
trace(intToStr(m.ModelNumber)); // crash
//trace(intToStr(ArrayByte[0])); // ok
//trace(intToStr(ArrayVec[0].X)); // ok]]>
</Expression>
</ZExpression>
</OnLoaded>
<Content>
<Array Name="ArrayFloat" SizeDim1="2"/>
<Array Name="ArrayInt" Type="1" SizeDim1="2"/>
<Array Name="ArrayString" Type="2" SizeDim1="2"/>
<Array Name="ArrayModel" Type="3" SizeDim1="2"/>
<Array Name="ArrayByte" Type="4" SizeDim1="2"/>
<Array Name="ArrayVec" Type="6" SizeDim1="2"/>
<Model Name="Model">
<Definitions>
<Variable Name="ModelNumber" Type="1"/>
</Definitions>
</Model>
</Content>
</ZApplication>
I started with directly tracing "ArrayModel[0].ModelNumber" yesterday, but in fact, "model m = ArrayModel[0]" is working. So it's not directly array of models that crashes.
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 9:52 am
by VilleK
I still can't figure it out. Do you have any way to try this on Linux 32-bit?
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 10:40 am
by Ats
I have the old i386 ready. It's working on it.
I can also test it on raspberry by flashing a new 32bits OS on a card, but I'll do that after lunch, as I need to setup everything.
(And I'll test on the same rasp with the 64bits OS too)
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 11:36 am
by VilleK
Please try this code on the crashing system and tell me what it outputs:
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
<OnLoaded>
<ZExpression>
<Expression>
<![CDATA[model[1] arr;
model m = createModel(Model);
arr[0]=m;
trace( intToStr(reinterpret_cast<int>(m)) );
m.ModelNumber = 1;
m = arr[0]; // ok
trace( intToStr(reinterpret_cast<int>(m)) );
trace(intToStr(m.ModelNumber)); // crash]]>
</Expression>
</ZExpression>
</OnLoaded>
<Content>
<Model Name="Model">
<Definitions>
<Variable Name="ModelNumber" Type="1"/>
</Definitions>
</Model>
</Content>
</ZApplication>
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 1:31 pm
by Ats
Here's the result on linux x86_64:
Code: Select all
1506279808
1506279808
An unhandled exception occurred at $000000000042691D:
EAccessViolation: Access violation
$000000000042691D
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 2:32 pm
by VilleK
Please try passing "-gl" option to Freepascal when building binary. That should hopefully make it display line number and source file when it shows the EAccessViolation: Access violation error.
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 2:39 pm
by Ats
I didn't know I could build a debug version of Player_linux.bin

So the fault is coming from line 2849 of ZExpressions.pas
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 3:28 pm
by VilleK
Ats wrote: ↑Thu Apr 29, 2021 2:39 pm
So the fault is coming from line 2849 of ZExpressions.pas
Interesting. And what if you run the string array example instead, where does it crash?
Re: Retrieving something from an Array crash on Linux
Posted: Thu Apr 29, 2021 3:48 pm
by Ats
I verified several times that I had everything right:
- Clean download of recent ZGE code
- Built Player_linux.bin for x86_64 debug
Your previous test still gives the same result, but test with array full of strings doesn't return a line number. Just:
Code: Select all
An unhandled exception occurred at $0000000000402A27:
EAccessViolation: Access violation
$0000000000402A27
...
But I got better information of the crash thanks to the Raspberry aarch64:
Your test:
Code: Select all
-1825435264
-1825435264
An unhandled exception occurred at $0000000000446210:
EAccessViolation: Access violation
$0000000000446210 EXECUTE, line 2849 of ZExpressions.pas
$0000000000443850 EXECUTE, line 764 of ZExpressions.pas
$000000000042FE8C EXECUTECOMMANDS, line 3676 of ZClasses.pas
$0000000000436094 RUN, line 582 of ZApplication.pas
$0000000000401640 main, line 90 of ZzDC.dpr
$0000007F9AB73218
$00000000004015E8
My test with array of string:
Code: Select all
An unhandled exception occurred at $0000000000402FF4:
EAccessViolation: Access violation
$0000000000402FF4
$0000000000422034
$0000000000444510 EXECUTE, line 1164 of ZExpressions.pas
$00000000004436BC RUNCODE, line 700 of ZExpressions.pas
$0000000000443850 EXECUTE, line 764 of ZExpressions.pas
$000000000042FE8C EXECUTECOMMANDS, line 3676 of ZClasses.pas
$0000000000436094 RUN, line 582 of ZApplication.pas
$0000000000401640 main, line 90 of ZzDC.dpr
$0000007F8CEF1218
$00000000004015E8
Re: Retrieving something from an Array crash on Linux
Posted: Fri Apr 30, 2021 7:29 am
by VilleK
What about a even simpler test: