View Issue Details

IDProjectCategoryView StatusLast Update
0038791FPCRTLpublic2021-04-23 22:20
ReporterPierre Muller Assigned ToMarco van de Voort  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformi386OSwin32 
Product Version3.3.1 
Summary0038791: Range check error inside trunk win32 GetLocalStr code
DescriptionBug probably introduced by rev 49244,
and thus assigned to Marco

Breakpoint 1, GETLOCALESTR (LID=1036, LT=40, DEF=0x82632c 'AM', result=0x110d120c 'dddd d MMMM yyyy') at C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp:1044
1044 begin
(gdb) n
1045 L := GetLocaleInfoW(LID, LT, nil, 0);
(gdb)
1046 if L > 0 then
(gdb)
1048 SetLength(Buf,L-1); // L includes terminating NULL
(gdb) p L
$2 = 1
(gdb) n
1049 L := GetLocaleInfoW(LID, LT, @Buf[1], L);
(gdb) p LT
$3 = 40
(gdb) p L
$4 = 1
(gdb) n
An unhandled exception occurred at $0042A7E2:
ERangeError: Range check error
  $0042A7E2 GETLOCALESTR, line 1049 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042B035 GETLOCALEFORMATSETTINGS, line 1219 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042B365 GETFORMATSETTINGS, line 1242 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042B59B INITINTERNATIONAL, line 1321 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042C740 SYSUTILS_$$_init$, line 1864 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0041106A fpc_initializeunits, line 1101 of C:/pas/pure-trunk/fpcsrc/rtl/inc/system.inc
  $00401AB8 main, line 292 of pp.pas


Program exited with code 0331.
(gdb)
Steps To Reproducecycle trunk revision 49246 on i386-win32 with

make distclean cycle OPT="-n -glttt -CriotR"
Additional Informationppc1.exe fails even to report version:

C:\pas\pure-trunk\fpcsrc\compiler>ppc1 -iV
An unhandled exception occurred at $0042A7E2:
ERangeError: Range check error
  $0042A7E2 GETLOCALESTR, line 1049 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042B035 GETLOCALEFORMATSETTINGS, line 1219 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042B365 GETFORMATSETTINGS, line 1242 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042B59B INITINTERNATIONAL, line 1321 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0042C740 SYSUTILS_$$_init$, line 1864 of C:/pas/pure-trunk/fpcsrc/rtl/win/sysutils.pp
  $0041106A fpc_initializeunits, line 1101 of C:/pas/pure-trunk/fpcsrc/rtl/inc/system.inc
  $00401AB8 main, line 292 of pp.pas

 
TagsNo tags attached.
Fixed in Revision49250
FPCOldBugId
FPCTarget-
Attached Files

Activities

LacaK

2021-04-23 07:18

developer   ~0130533

May be that, L can be 1 then IMO we can change:

 if L > 0 then
  begin
  SetLength(Buf,L-1); // L includes terminating NULL
  if L > 1 then // <- ADDED
    L := GetLocaleInfoW(LID, LT, @Buf[1], L);
  Result:=Buf; // <- HERE change please firs letter uppercase ;-)
  end

Marco van de Voort

2021-04-23 22:20

manager   ~0130552

Resolved as LacaK indicated

Issue History

Date Modified Username Field Change
2021-04-22 23:53 Pierre Muller New Issue
2021-04-22 23:53 Pierre Muller Status new => assigned
2021-04-22 23:53 Pierre Muller Assigned To => Marco van de Voort
2021-04-23 07:18 LacaK Note Added: 0130533
2021-04-23 22:20 Marco van de Voort Status assigned => resolved
2021-04-23 22:20 Marco van de Voort Resolution open => fixed
2021-04-23 22:20 Marco van de Voort Fixed in Revision => 49250
2021-04-23 22:20 Marco van de Voort FPCTarget => -
2021-04-23 22:20 Marco van de Voort Note Added: 0130552