RTL - Sys - SysUtils
TMultiReadExclusiveWriteSynchronizer.BeginWrite can generate
range check errors because of incorrect declaration of FWriteRequestorID
1.02
2.01
3.0
3.01
3.02
4.0
4.01
4.02
4.03
5.0
5.01
6.0
6.01
6.02
Kylix 1.0
N/A
N/A
N/A
N/A
N/A
Exists
Exists
Exists
Exists
Exists
Exists
Fixed
Fixed
Fixed
Unknown
Description
Reported by Max Masyutin
FWriteRequestorID is declared as Integer and used to store a
Thread's ID which is DWORD.
procedure TMultiReadExclusiveWriteSynchronizer.BeginWrite;
begin
EnterCriticalSection(FLock); // Block new read or write ops from starting
if not FWriting then
begin
FWriteRequestorID := GetCurrentThreadID; // Indicate that
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
On Windows 98, GetCurrentThreadID may return, e.g. $FFFB2453, which is
bigger than MaxInt.
Solution / workaround
Modify sysutils.pas so FWriteRequestorID is declared as DWORD.
Daniel Calcoen adds (19 Nov 2000):
In addition to FWriteRequestorID you must change to DWORD the ThreadID
field from
TActiveThreadRecord = record
ThreadID: DWORD; // change from Integer; bug 619 fix
RecursionCount: Integer;
end;
and also several ThreadID variables across sysutils.pas.