View Issue Details

IDProjectCategoryView StatusLast Update
0035979FPCCompilerpublic2019-08-18 14:30
ReporterSolstice ProjektAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version3.0.4Product Build2017/10/06 
Target VersionFixed in Version 
Summary0035979: RangeChecking messes with absolute'd arrays.
DescriptionSee Title. I have no better description.
The example shows it all.
Steps To Reproduce{$R+}
program test_absolute;
Uses Windows, SysUtils;
Var
    There : Pointer;
    Here : Array of Byte absolute There;
    q : dword;

Procedure RangeCheckError(_q : dword);
Var
    _dest : Array of Byte absolute _q;

Begin
    WriteLn(qword(@q));
    WriteLn(qword(@_q));
    WriteLn(qword(@_dest[0]));
End;

Begin
    There := VirtualAlloc(nil,1024*1024,MEM_COMMIT or MEM_RESERVE,PAGE_READWRITE);
    WriteLn(qword(There));
    WriteLn(qword(@Here[0]));
End.

Output:
----------------------------------------------------------------------------------------
97124352
An unhandled exception occurred at $00000001000066F7:
EAccessViolation: Access violation
  $00000001000066F7
  $0000000100001617
  $0000000100001656
  $000000010000C223
  $000000010000CCD1
  $00007FFA77337BD4
  $00007FFA783CCE71
----------------------------------------------------------------------------------------

.. but ONLY when RangeChecking is enabled. It works fine otherwise!
Note that using GetMem instead of VirtualAlloc ALWAYS works.

Output with RangeChecking commented out:
----------------
20971520
20971520
----------------

... as it should be.

I have found different issues with "absolute" when used with parameters in procedures/functions,
but one at a time, I guess.

What's not working here?

Thank you.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Solstice Projekt

2019-08-18 14:20

reporter   ~0117729

Apologies for the misleading "RangeCheckError" Procedure. I thought I've removed it before posting.
It doesn't add anything to this report.

Florian

2019-08-18 14:30

administrator   ~0117730

Dynamic arrays expect some internal data being setup. If you don't do so, it is pure coincidence if it works with/without range checking/getmem/virtualalloc whatever.

Issue History

Date Modified Username Field Change
2019-08-18 14:18 Solstice Projekt New Issue
2019-08-18 14:20 Solstice Projekt Note Added: 0117729
2019-08-18 14:30 Florian Assigned To => Florian
2019-08-18 14:30 Florian Status new => resolved
2019-08-18 14:30 Florian Resolution open => no change required
2019-08-18 14:30 Florian FPCTarget => -
2019-08-18 14:30 Florian Note Added: 0117730