HuubGitHub / dwscript

Automatically exported from code.google.com/p/dwscript
1 stars 0 forks source link

function SupportsSRW in dwsXPlatform range check error in 64-bit executable #463

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile a 64-bit executable using dwsXPlatform and dwsGlobalVarsFunctions
2. Make sure Range Checks are switch on in compiler options
3. Run the .exe on a 64-bit Windows version

What is the expected output? 

The EXE runs.

What do you see instead?

Error 216 - range check error is raised during intialization

What version of the product are you using? 

XE2 Update 4, latest trunk of dwscript

On what operating system?

Windows 8.1 64-bit

Please provide any additional information below.

function SupportsSRW : Boolean;
var
h : Integer;
// h should be defined as THandle (or HMODULE) - not Integer
begin
if not vSupportsSRWChecked then begin
vSupportsSRWChecked:=True;
h:=GetModuleHandle('kernel32');
AcquireSRWLockExclusive:=GetProcAddress(h, 'AcquireSRWLockExclusive');
ReleaseSRWLockExclusive:=GetProcAddress(h, 'ReleaseSRWLockExclusive');
AcquireSRWLockShared:=GetProcAddress(h, 'AcquireSRWLockShared');
ReleaseSRWLockShared:=GetProcAddress(h, 'ReleaseSRWLockShared');
end;
Result:=Assigned(AcquireSRWLockExclusive);
end;

First failure seems to be trigger by this:

constructor TMultiReadSingleWrite.Create(forceFallBack : Boolean = False);
begin
   if forceFallBack or not SupportsSRW then
      FCS:=TFixedCriticalSection.Create;
end

which in turn is called from this:

dwsGlobalVarsFunctions.pas
    vGlobalVarsCS := TMultiReadSingleWrite.Create;

Original issue reported on code.google.com by locopa...@gmail.com on 10 Apr 2014 at 12:28

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r2507.

Original comment by zar...@gmail.com on 10 Apr 2014 at 1:11