The Delphi Bug List

Entry No.
619
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/AN/AN/AN/AN/AExistsExistsExistsExistsExistsExistsFixedFixedFixedUnknown
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.

Latest update of this entry: 2002-04-09

Post a comment on this bug


Index page
Delphi Bug List home page
The Delphi Bug Lists are presently maintained by Jordan Russell, who has taken over this task from Reinier Sterkenburg since August 2000.
All feedback is appreciated. See also the feedback section of the Delphi Bug List home page.