View Issue Details

IDProjectCategoryView StatusLast Update
0034818FPCCompilerpublic2019-01-14 21:45
ReporterBenito van der ZanderAssigned ToFlorian 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSlinuxOS Versionopensuse
Product Version3.3.1Product Buildr40681 
Target Version3.3.1Fixed in Version3.3.1 
Summary0034818: out of memory when compiling with -Os1
DescriptionCompiling FLRE with -Os1 uses so much memory that the compilation does not end before the oom killer gets rid of fpc.
Steps To Reproduce$ git clone git@github.com:BeRo1985/flre.git
$ cd flre/src/
$ fpc -Os1 FLRE.pas
Free Pascal Compiler version 3.3.1 [2019/01/01] for x86_64
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling FLRE.pas
FLRE.pas(4845,5) Note: Local variable "Index" not used
FLRE.pas(4846,5) Note: Local variable "CurrentChar" not used
FLRE.pas(5013,5) Note: Local variable "Index" not used
FLRE.pas(5014,5) Note: Local variable "CurrentChar" not used
FLRE.pas(5174,5) Note: Local variable "Index" not used
FLRE.pas(5175,5) Note: Local variable "CurrentChar" not used
FLRE.pas(5357,5) Note: Local variable "Index" not used
FLRE.pas(5358,5) Note: Local variable "CurrentChar" not used
FLRE.pas(5474,5) Note: Local variable "Index" not used
FLRE.pas(5475,5) Note: Local variable "CurrentChar" not used
FLRE.pas(5642,5) Note: Local variable "Index" not used
FLRE.pas(5643,5) Note: Local variable "CurrentChar" not used
FLRE.pas(8087,3) Error: Compilation raised exception internally
Error: /usr/local/bin/ppcx64 can't be executed, error message: Failed to execute "/usr/local/bin/ppcx64", error code: -9
Additional InformationI have 8GB RAM
TagsNo tags attached.
Fixed in Revision40851
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0034762 resolvedFlorian [Patch] Speed improvement in case blocks 

Activities

Benito van der Zander

2019-01-05 15:34

reporter   ~0113190

in r40721

Martok

2019-01-05 18:12

reporter   ~0113194

Last edited: 2019-01-05 22:07

View 3 revisions

Derived smaller example, reproducibly crashes with -Os:

program Project1;

var CharValue: cardinal;
begin
  case CharValue of
   $00000000..$0000007f:begin
    WriteLn(1);
   end;
   $00000080..$000007ff:begin
    WriteLn(1);
   end;
   $00000800..$0000ffff:begin
    WriteLn(1);
   end;
   $00010000..$0010ffff:begin
    WriteLn(1);
   end;
   $00200000..$03ffffff:begin
    WriteLn(1);
   end;
  end;
end.

Edit: tested on win32, FPC r40748. It does seem to compile, but needs in excess of 4GB RAM.

Edit2: retested on a machine with more RAM. win32 fails as the process address space is exhausted. win64 (native, not crosscompiler) consumes all the host memory, then fails.

Bart Broersma

2019-01-05 18:18

reporter   ~0113195

That example compiles fine with r40745 on win32 (and cross-compiles to win64).

Bart Broersma

2019-01-05 23:30

reporter   ~0113197

Last edited: 2019-01-06 00:47

View 4 revisions

Sorry, my mistake: crashes here as well (r40745 on win32).

Martok

2019-01-06 18:13

reporter   ~0113214

This is the same issue as 0032115. The (hacky) fix in r37390 was undone with the jumptable rework.

Size optimization checks should be done differently... in this case, a 6-cmps linear list would be *much* smaller than a 256MiB continuum jumptable.

J. Gareth Moreton

2019-01-14 15:28

developer   ~0113403

I just wanted to add a note. With my jumptable rework back in 0034762, tables will not be allowed to exceed 2,048 entries, which I decided in order to prevent such situations as you describe. At least that was my intention.

Florian

2019-01-14 21:44

administrator   ~0113411

I found the limitation to 2048 elements rather arbitrary. If somebody writes a case statement with 4000 elements (e.g. something autogenerated), a jump table is still fine. Further, it was limited to x86-64.

Issue History

Date Modified Username Field Change
2019-01-05 15:07 Benito van der Zander New Issue
2019-01-05 15:34 Benito van der Zander Note Added: 0113190
2019-01-05 18:12 Martok Note Added: 0113194
2019-01-05 18:18 Bart Broersma Note Added: 0113195
2019-01-05 19:37 Martok Note Edited: 0113194 View Revisions
2019-01-05 22:07 Martok Note Edited: 0113194 View Revisions
2019-01-05 23:30 Bart Broersma Note Added: 0113197
2019-01-05 23:36 Bart Broersma Note Edited: 0113197 View Revisions
2019-01-06 00:46 Bart Broersma Note Edited: 0113197 View Revisions
2019-01-06 00:47 Bart Broersma Note Edited: 0113197 View Revisions
2019-01-06 18:13 Martok Note Added: 0113214
2019-01-13 11:32 Florian Fixed in Revision => 40851
2019-01-13 11:32 Florian Status new => resolved
2019-01-13 11:32 Florian Fixed in Version => 3.3.1
2019-01-13 11:32 Florian Resolution open => fixed
2019-01-13 11:32 Florian Assigned To => Florian
2019-01-14 15:28 J. Gareth Moreton Note Added: 0113403
2019-01-14 15:28 J. Gareth Moreton Status resolved => feedback
2019-01-14 15:28 J. Gareth Moreton Resolution fixed => reopened
2019-01-14 15:28 J. Gareth Moreton Status feedback => closed
2019-01-14 15:28 J. Gareth Moreton Resolution reopened => fixed
2019-01-14 15:28 J. Gareth Moreton Target Version => 3.3.1
2019-01-14 15:28 J. Gareth Moreton Status closed => feedback
2019-01-14 15:28 J. Gareth Moreton Resolution fixed => reopened
2019-01-14 15:29 J. Gareth Moreton Status feedback => resolved
2019-01-14 15:29 J. Gareth Moreton Resolution reopened => fixed
2019-01-14 21:44 Florian Note Added: 0113411
2019-01-14 21:45 Florian Relationship added related to 0034762