View Issue Details

IDProjectCategoryView StatusLast Update
0036299FPCCompilerpublic2019-11-12 21:03
ReporterJ. Gareth MoretonAssigned ToFlorian 
PriorityhighSeveritymajorReproducibilitysometimes
Status resolvedResolutionfixed 
Platformx86_64-linuxOSUbuntuOS Version16.04
Product Version3.3.1Product Buildr43453 
Target VersionFixed in Version3.3.1 
Summary0036299: [Patch] Bug fix for jump optimisations under debug mode
DescriptionWhen building packages with DEBUG=1, some of the files can sometimes raise internal error 2018062911 under x86_64-linux. This was due to the presence of a "tai_tempalloc" entry that the code wasn't expecting in OptPass2Jcc.

Now, for both OptPass2Jcc and SkipLabelFast, if any entries are found that belong to the SkipInstr set (which includes tai_tempalloc), the stripping code will move to the next entry and leave it alone. The internal error is still raised though if it isn't a label or align and doesn't belong to the set (i.e. is an instruction or something else that affects program flow in some way).
Steps To ReproduceApply patch, then run the following command from an x86_64 Linux terminal (specifying directories and prefixes if needs be):

"make distclean all install DEBUG=1 NOGDB=1 NOGDBMI=1 GDBMI=1"

Confirm that Internal Error 2018062911 is no longer raised when packages are compiled.
Additional InformationAdditionally, SkipLabelFast now has a check that will not remove alignment fields if debug info is present, so such behaviour is consistent throughout the compiler.
Tagscompiler, debug, internal error, linux, patch, x86_64
Fixed in Revision43455
FPCOldBugId
FPCTarget-
Attached Files
  • jump-optimizations-debug-fix.patch (2,136 bytes)
    Index: compiler/aoptobj.pas
    ===================================================================
    --- compiler/aoptobj.pas	(revision 43453)
    +++ compiler/aoptobj.pas	(working copy)
    @@ -1789,8 +1789,15 @@
                 ait_align:
                   begin
                     tmp := tai(hp.Next);
    -                asml.Remove(hp);
    -                hp.Free;
    +                if not(
    +                  (cs_debuginfo in current_settings.moduleswitches) or
    +                  (cs_use_lineinfo in current_settings.globalswitches)
    +                ) then
    +                  { Don't remove aligns if debuginfo is present }
    +                  begin
    +                    asml.Remove(hp);
    +                    hp.Free;
    +                  end;
                     hp := tmp;
                     { Control flow will now return to 'repeat' }
                   end;
    @@ -1807,7 +1814,13 @@
                     Exit;
                   end;
                 else
    -              InternalError(2019110801);
    +              begin
    +                { Might be a comment or temporary allocation entry }
    +                if not (hp.typ in SkipInstr) then
    +                  InternalError(2019110801);
    +
    +                hp := tai(hp.Next);
    +              end;
               end;
             until False;
           end;
    Index: compiler/x86/aoptx86.pas
    ===================================================================
    --- compiler/x86/aoptx86.pas	(revision 43453)
    +++ compiler/x86/aoptx86.pas	(working copy)
    @@ -3433,7 +3433,14 @@
                                       Continue;
                                     end;
                                   else
    -                                InternalError(2018062911);
    +                                begin
    +                                  { Might be a comment or temporary allocation entry }
    +                                  if not (hp2.typ in SkipInstr) then
    +                                    InternalError(2018062911);
    +
    +                                  hp2 := tai(hp2.Next);
    +                                  Continue;
    +                                end;
                                 end;
     
                               until False;
    

Relationships

child of 0036271 resolvedFlorian [Patch] Jump optimisations in code generator 

Activities

J. Gareth Moreton

2019-11-12 03:19

developer  

jump-optimizations-debug-fix.patch (2,136 bytes)
Index: compiler/aoptobj.pas
===================================================================
--- compiler/aoptobj.pas	(revision 43453)
+++ compiler/aoptobj.pas	(working copy)
@@ -1789,8 +1789,15 @@
             ait_align:
               begin
                 tmp := tai(hp.Next);
-                asml.Remove(hp);
-                hp.Free;
+                if not(
+                  (cs_debuginfo in current_settings.moduleswitches) or
+                  (cs_use_lineinfo in current_settings.globalswitches)
+                ) then
+                  { Don't remove aligns if debuginfo is present }
+                  begin
+                    asml.Remove(hp);
+                    hp.Free;
+                  end;
                 hp := tmp;
                 { Control flow will now return to 'repeat' }
               end;
@@ -1807,7 +1814,13 @@
                 Exit;
               end;
             else
-              InternalError(2019110801);
+              begin
+                { Might be a comment or temporary allocation entry }
+                if not (hp.typ in SkipInstr) then
+                  InternalError(2019110801);
+
+                hp := tai(hp.Next);
+              end;
           end;
         until False;
       end;
Index: compiler/x86/aoptx86.pas
===================================================================
--- compiler/x86/aoptx86.pas	(revision 43453)
+++ compiler/x86/aoptx86.pas	(working copy)
@@ -3433,7 +3433,14 @@
                                   Continue;
                                 end;
                               else
-                                InternalError(2018062911);
+                                begin
+                                  { Might be a comment or temporary allocation entry }
+                                  if not (hp2.typ in SkipInstr) then
+                                    InternalError(2018062911);
+
+                                  hp2 := tai(hp2.Next);
+                                  Continue;
+                                end;
                             end;
 
                           until False;

Issue History

Date Modified Username Field Change
2019-11-12 03:19 J. Gareth Moreton New Issue
2019-11-12 03:19 J. Gareth Moreton File Added: jump-optimizations-debug-fix.patch
2019-11-12 03:19 J. Gareth Moreton Relationship added child of 0036271
2019-11-12 03:19 J. Gareth Moreton Tag Attached: compiler
2019-11-12 03:19 J. Gareth Moreton Tag Attached: patch
2019-11-12 03:19 J. Gareth Moreton Tag Attached: debug
2019-11-12 03:19 J. Gareth Moreton Tag Attached: internal error
2019-11-12 03:19 J. Gareth Moreton Tag Attached: x86_64
2019-11-12 03:19 J. Gareth Moreton Tag Attached: linux
2019-11-12 03:21 J. Gareth Moreton Priority normal => high
2019-11-12 03:21 J. Gareth Moreton Severity minor => major
2019-11-12 03:21 J. Gareth Moreton Steps to Reproduce Updated View Revisions
2019-11-12 03:21 J. Gareth Moreton FPCTarget => -
2019-11-12 03:59 J. Gareth Moreton Description Updated View Revisions
2019-11-12 21:03 Florian Assigned To => Florian
2019-11-12 21:03 Florian Status new => resolved
2019-11-12 21:03 Florian Resolution open => fixed
2019-11-12 21:03 Florian Fixed in Version => 3.3.1
2019-11-12 21:03 Florian Fixed in Revision => 43455