View Issue Details

IDProjectCategoryView StatusLast Update
0035065FPCCompilerpublic2019-03-16 16:23
ReporterJ. Gareth MoretonAssigned ToPierre Muller 
PriorityurgentSeveritymajorReproducibilityrandom
Status resolvedResolutionfixed 
Platformx86_64-win64OSMicrosoft WindowsOS Version10 Professional
Product Version3.3.1Product BuildCross-platform 
Target Version3.3.1Fixed in Version3.3.1 
Summary0035065: [Patch] Internal Error 200208181 fix
DescriptionThere's a critical bug in the "tai_cpu_abstract.ppuload" constructor. When loading in the operand count, it doesn't actually set ops, the variable that keeps track of this, which remains at zero. As a result, the loader skips loading in the instruction's operands and moves onto the next instruction, where instead of data for the next tai object in the PPU file, there's operand data instead, and because of this, Internal Error 200208181 is raised because of a signature mismatch.
Steps To ReproduceApply patch and confirm successful compilation of the compiler.
Additional InformationNormally this bug is impossible to trigger because it seems that nodes of type asmn are not usually saved to the PPU file. I have, however, triggered it on my own work with the compiler, and even if the code is rarely triggered, it is still a bug with a known way of triggering it (have a construct where a node of type "asmn" is saved to a PPU file, then try to load the PPU file on a subsequent compilation of your project).
Tagscompiler, internal error, patch
Fixed in Revision41310
FPCOldBugId0
FPCTarget
Attached Files
  • 200208181-fix.patch (746 bytes)
    Index: compiler/aasmtai.pas
    ===================================================================
    --- compiler/aasmtai.pas	(revision 41309)
    +++ compiler/aasmtai.pas	(working copy)
    @@ -2926,9 +2926,10 @@
             i : integer;
           begin
             inherited ppuload(t,ppufile);
    -        { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
    +        { hopefully, we don't get problems with big/little endian here when cross compiling :/ }
             ppufile.getdata(condition,sizeof(tasmcond));
    -        allocate_oper(ppufile.getbyte);
    +        ops := ppufile.getbyte;
    +        allocate_oper(ops);
             for i:=0 to ops-1 do
               ppuloadoper(ppufile,oper[i]^);
             opcode:=tasmop(ppufile.getword);
    
    200208181-fix.patch (746 bytes)

Relationships

child of 0035232 closedJ. Gareth Moreton [Feature] Support for "inline" on some pure x86 assembler routines (subject to certain restrictions) 

Activities

J. Gareth Moreton

2019-02-12 06:43

developer  

200208181-fix.patch (746 bytes)
Index: compiler/aasmtai.pas
===================================================================
--- compiler/aasmtai.pas	(revision 41309)
+++ compiler/aasmtai.pas	(working copy)
@@ -2926,9 +2926,10 @@
         i : integer;
       begin
         inherited ppuload(t,ppufile);
-        { hopefully, we don't get problems with big/litte endian here when cross compiling :/ }
+        { hopefully, we don't get problems with big/little endian here when cross compiling :/ }
         ppufile.getdata(condition,sizeof(tasmcond));
-        allocate_oper(ppufile.getbyte);
+        ops := ppufile.getbyte;
+        allocate_oper(ops);
         for i:=0 to ops-1 do
           ppuloadoper(ppufile,oper[i]^);
         opcode:=tasmop(ppufile.getword);
200208181-fix.patch (746 bytes)

J. Gareth Moreton

2019-02-12 07:16

developer   ~0114047

Extra note: the "allocate_oper" method only allocates memory for the operands - it doesn't actually set the "ops" field.

Pierre Muller

2019-02-12 08:20

developer   ~0114048

Patch committed,
thanks!

  Could you tell us how you are able to insert
asmn into PPU files?

  Up to now, I think that asm directive leads to
removal of po_inline IIRC...

Pierre

Issue History

Date Modified Username Field Change
2019-02-12 06:43 J. Gareth Moreton New Issue
2019-02-12 06:43 J. Gareth Moreton File Added: 200208181-fix.patch
2019-02-12 06:44 J. Gareth Moreton Priority normal => urgent
2019-02-12 06:44 J. Gareth Moreton Severity minor => major
2019-02-12 06:44 J. Gareth Moreton Tag Attached: compiler
2019-02-12 06:44 J. Gareth Moreton Tag Attached: internal error
2019-02-12 06:44 J. Gareth Moreton Tag Attached: patch
2019-02-12 07:16 J. Gareth Moreton Note Added: 0114047
2019-02-12 08:20 Pierre Muller Fixed in Revision => 41310
2019-02-12 08:20 Pierre Muller Note Added: 0114048
2019-02-12 08:20 Pierre Muller Status new => resolved
2019-02-12 08:20 Pierre Muller Fixed in Version => 3.3.1
2019-02-12 08:20 Pierre Muller Resolution open => fixed
2019-02-12 08:20 Pierre Muller Assigned To => Pierre Muller
2019-02-12 08:20 Pierre Muller Target Version 3.2.0 => 3.3.1
2019-03-16 16:23 J. Gareth Moreton Relationship added child of 0035232