View Issue Details

IDProjectCategoryView StatusLast Update
0030205FPCCompilerpublic2019-02-11 00:06
ReporterMax NazhalovAssigned ToSven Barth 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWin32OSOS Version
Product Version3.1.1Product Buildr33559 
Target VersionFixed in Version3.3.1 
Summary0030205: [Win32-SEH] Internal error 201201143 when dealing with managed locals in subroutine
DescriptionFPC build command [native-Win32]:
make OPT="-Xs -dTEST_WIN32_SEH -gl" INSTALL_PREFIX=%INST% clean all install

Sample program:
procedure ietest( var f: ansistring );
var
  x: ansistring;
begin
  x :='1234';
  f := x;
end;
begin
end.

Sample program build command:
fpc -n -l -vewnhivp -FuD:\Prog\fpc\units\i386-win32\rtl -Cccdecl test3.pp

Sample build output:
Free Pascal Compiler version 3.1.1 [2016/05/28] for i386
Copyright (c) 1993-2016 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test3.pp
test3.pp(4,1) Fatal: Internal error 201201143
  $004FC4F2 GEN_LOAD_FRAME_FOR_EXCEPTFILTER, line 1932 of ncgutil.pas
  $0051AC10 TCGX86__G_PROC_ENTRY, line 3047 of ./x86/cgx86.pas
  $005285E1 THLCG2LL__G_PROC_ENTRY, line 978 of hlcg2ll.pas
  $004FBA26 GEN_PROC_ENTRY_CODE, line 1415 of ncgutil.pas
  $0050246B TCGPROCINFO__GENERATE_CODE, line 1628 of psub.pas
  $0050169D TCGPROCINFO__GENERATE_EXCEPTFILTER, line 1161 of psub.pas
  $00501609 TCGPROCINFO__GENERATE_CODE_TREE, line 1107 of psub.pas
  $0050323A READ_PROC, line 2154 of psub.pas
  $005036B3 READ_DECLARATIONS, line 2322 of psub.pas
Fatal: Compilation aborted
Error: D:\Prog\FPC\bin\i386-win32\ppc386.exe returned an error exitcode

Notes:
 - FPC revision r33559 slightly modified for obtaining stack backtrace on IE: disabled {$ifdef EXTDEBUG} in .\src\compiler\comphook.pas::def_internalerror()
 - ie201201143 triggered only via -Cccdecl command line option; declaring procedure as cdecl does not matter.
Steps To ReproduceSee attached archive for tree.log & fpcdebug.txt
TagsNo tags attached.
Fixed in Revision41277
FPCOldBugId
FPCTarget
Attached Files
  • ie201201143_r33559.zip (3,917 bytes)
  • 30205.patch (651 bytes)
    Index: nflw.pas
    ===================================================================
    --- nflw.pas	(revision 33753)
    +++ nflw.pas	(working copy)
    @@ -2193,6 +2195,9 @@
               nested procvars modeswitch is active. We must be independent of this switch. }
             exclude(result.procoptions,po_delphi_nested_cc);
             result.proctypeoption:=potype_exceptfilter;
    +        { Also be independent of -CCxxx switch. }
    +        result.proccalloption:=pocall_default;
    +        include(result.procoptions,po_hascallingconvention);
             handle_calling_convention(result);
             sym:=cprocsym.create('$fin$'+tostr(seq));
             st.insert(sym);
    
    30205.patch (651 bytes)
  • out01.txt (2,200 bytes)
    Free Pascal Compiler version 3.3.1-r40978 [2019/01/21] for i386
    Copyright (c) 1993-2018 by Florian Klaempfl and others
    Target OS: Win32 for i386
    Compiling ./test3.pp
    test3.pp(4,1) Note: tgobj: (AllocTemp) lasttemp set to -4
    test3.pp(4,1) Note: tgobj: (AllocTemp) temp of size 4 type persistent requested, allocated at offset -4
    test3.pp(5,3) Note: tgobj: (FreeTemp) freeing of temp at pos -4 requested
    test3.pp(5,3) Note: tgobj: (Freetemp) temp at pos -4 has different type (persistent), not releasing
    test3.pp(6,3) Note: tgobj: (FreeTemp) freeing of temp at pos -4 requested
    test3.pp(6,3) Note: tgobj: (Freetemp) temp at pos -4 has different type (persistent), not releasing
    test3.pp(7,1) Note: tgobj: (FreeTemp) freeing of temp at pos -4 requested
    test3.pp(7,1) Note: tgobj: (Freetemp) temp at pos -4 has different type (persistent), not releasing
    test3.pp(7,1) Note: Change of bind type of symbol P$PROGRAM$_$IETEST$ANSISTRING_$$_fin$00000001 from external to local after use
    test3.pp(7,1) Fatal: Internal error 201201143
      $081C923F  GEN_LOAD_FRAME_FOR_EXCEPTFILTER,  line 1860 of ncgutil.pas
      $081C5C9F  TCGX86__G_PROC_ENTRY,  line 3514 of x86/cgx86.pas
      $081D0EDF  THLCG2LL__G_PROC_ENTRY,  line 978 of hlcg2ll.pas
      $081C852A  GEN_PROC_ENTRY_CODE,  line 1378 of ncgutil.pas
      $081F4DCF  TCGPROCINFO__GENERATE_CODE,  line 1748 of psub.pas
      $081F3B35  TCGPROCINFO__GENERATE_EXCEPTFILTER,  line 1207 of psub.pas
      $081F4849  TCGPROCINFO__GENERATE_CODE,  line 1597 of psub.pas
      $081F3A72  TCGPROCINFO__GENERATE_CODE_TREE,  line 1153 of psub.pas
      $081F5AE3  READ_PROC_BODY,  line 2151 of psub.pas
      $081F603A  READ_PROC,  line 2354 of psub.pas
      $081F6622  READ_DECLARATIONS,  line 2538 of psub.pas
      $081F1BF2  BLOCK,  line 332 of psub.pas
      $081F55E9  TCGPROCINFO__PARSE_BODY,  line 1982 of psub.pas
      $08270B50  PROC_PROGRAM,  line 2166 of pmodules.pas
      $08238931  COMPILE,  line 393 of parser.pas
      $0807824A  COMPILE,  line 278 of compiler.pas
      $0804927F  main,  line 276 of pp.pas
      $08049032  _FPC_PROC_START
    Fatal: Compilation aborted
    Error: /mnt/shares/ohjelmointi2/fpc/i386/trunk/3.3.1/binary/trunk/bin/i386-linux/ppc386 returned an error exitcode
    
    out01.txt (2,200 bytes)
  • fpcdebug.zip (2,510 bytes)
  • tree.zip (1,329 bytes)
  • procdefutil.pas-30205.patch (980 bytes)
    Index: compiler/procdefutil.pas
    ===================================================================
    --- compiler/procdefutil.pas	(revision 41078)
    +++ compiler/procdefutil.pas	(working copy)
    @@ -36,7 +36,7 @@
     
       uses
         cutils,
    -    symbase,symsym,symtable,pparautl;
    +    symbase,symsym,symtable,pparautl,globtype;
     
     
       function create_outline_procdef(const basesymname: string; astruct: tabstractrecorddef; potype: tproctypeoption; resultdef: tdef): tprocdef;
    @@ -72,6 +72,9 @@
             nested procvars modeswitch is active. We must be independent of this switch. }
           exclude(result.procoptions,po_delphi_nested_cc);
           result.proctypeoption:=potype;
    +      { Also be independent of -CCxxx switch. }
    +      result.proccalloption:=pocall_default;
    +      include(result.procoptions,po_hascallingconvention);
           handle_calling_convention(result,hcc_default_actions_impl);
           sym:=cprocsym.create(basesymname+result.unique_id_str);
           st.insert(sym);
    

Relationships

child of 0028756 new Enable Win32 SEH by default 

Activities

Max Nazhalov

2016-05-28 19:01

reporter  

ie201201143_r33559.zip (3,917 bytes)

Sergei Gorelkin

2016-05-29 08:19

developer   ~0092877

The calling convention of procedure itself does not matter here. Apparently -CCcdecl gets applied to the hidden exception handling procedure which is generated by compiler (in ttryfinallynode.create_finalizer_procdef method).

I'm attaching a presumable fix, but need some time to test and make sure it doesn't break anything else (including win64 SEH that reuses same code).

Sergei Gorelkin

2016-05-29 08:20

developer  

30205.patch (651 bytes)
Index: nflw.pas
===================================================================
--- nflw.pas	(revision 33753)
+++ nflw.pas	(working copy)
@@ -2193,6 +2195,9 @@
           nested procvars modeswitch is active. We must be independent of this switch. }
         exclude(result.procoptions,po_delphi_nested_cc);
         result.proctypeoption:=potype_exceptfilter;
+        { Also be independent of -CCxxx switch. }
+        result.proccalloption:=pocall_default;
+        include(result.procoptions,po_hascallingconvention);
         handle_calling_convention(result);
         sym:=cprocsym.create('$fin$'+tostr(seq));
         st.insert(sym);
30205.patch (651 bytes)

Max Nazhalov

2016-05-29 08:51

reporter   ~0092878

Well, at least it fixes Win32 target for me, thanks.

Cyrax

2019-01-21 22:43

reporter   ~0113557

After trunk r40773, attached patch fails to apply correctly.

Cyrax

2019-01-21 23:46

reporter  

out01.txt (2,200 bytes)
Free Pascal Compiler version 3.3.1-r40978 [2019/01/21] for i386
Copyright (c) 1993-2018 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling ./test3.pp
test3.pp(4,1) Note: tgobj: (AllocTemp) lasttemp set to -4
test3.pp(4,1) Note: tgobj: (AllocTemp) temp of size 4 type persistent requested, allocated at offset -4
test3.pp(5,3) Note: tgobj: (FreeTemp) freeing of temp at pos -4 requested
test3.pp(5,3) Note: tgobj: (Freetemp) temp at pos -4 has different type (persistent), not releasing
test3.pp(6,3) Note: tgobj: (FreeTemp) freeing of temp at pos -4 requested
test3.pp(6,3) Note: tgobj: (Freetemp) temp at pos -4 has different type (persistent), not releasing
test3.pp(7,1) Note: tgobj: (FreeTemp) freeing of temp at pos -4 requested
test3.pp(7,1) Note: tgobj: (Freetemp) temp at pos -4 has different type (persistent), not releasing
test3.pp(7,1) Note: Change of bind type of symbol P$PROGRAM$_$IETEST$ANSISTRING_$$_fin$00000001 from external to local after use
test3.pp(7,1) Fatal: Internal error 201201143
  $081C923F  GEN_LOAD_FRAME_FOR_EXCEPTFILTER,  line 1860 of ncgutil.pas
  $081C5C9F  TCGX86__G_PROC_ENTRY,  line 3514 of x86/cgx86.pas
  $081D0EDF  THLCG2LL__G_PROC_ENTRY,  line 978 of hlcg2ll.pas
  $081C852A  GEN_PROC_ENTRY_CODE,  line 1378 of ncgutil.pas
  $081F4DCF  TCGPROCINFO__GENERATE_CODE,  line 1748 of psub.pas
  $081F3B35  TCGPROCINFO__GENERATE_EXCEPTFILTER,  line 1207 of psub.pas
  $081F4849  TCGPROCINFO__GENERATE_CODE,  line 1597 of psub.pas
  $081F3A72  TCGPROCINFO__GENERATE_CODE_TREE,  line 1153 of psub.pas
  $081F5AE3  READ_PROC_BODY,  line 2151 of psub.pas
  $081F603A  READ_PROC,  line 2354 of psub.pas
  $081F6622  READ_DECLARATIONS,  line 2538 of psub.pas
  $081F1BF2  BLOCK,  line 332 of psub.pas
  $081F55E9  TCGPROCINFO__PARSE_BODY,  line 1982 of psub.pas
  $08270B50  PROC_PROGRAM,  line 2166 of pmodules.pas
  $08238931  COMPILE,  line 393 of parser.pas
  $0807824A  COMPILE,  line 278 of compiler.pas
  $0804927F  main,  line 276 of pp.pas
  $08049032  _FPC_PROC_START
Fatal: Compilation aborted
Error: /mnt/shares/ohjelmointi2/fpc/i386/trunk/3.3.1/binary/trunk/bin/i386-linux/ppc386 returned an error exitcode
out01.txt (2,200 bytes)

Cyrax

2019-01-21 23:51

reporter  

fpcdebug.zip (2,510 bytes)

Cyrax

2019-01-21 23:51

reporter  

tree.zip (1,329 bytes)

Do-wan Kim

2019-01-26 07:51

reporter   ~0113628

After trunk r40773, it need to patch 'procdefutil.pas'.

Do-wan Kim

2019-01-27 01:59

reporter  

procdefutil.pas-30205.patch (980 bytes)
Index: compiler/procdefutil.pas
===================================================================
--- compiler/procdefutil.pas	(revision 41078)
+++ compiler/procdefutil.pas	(working copy)
@@ -36,7 +36,7 @@
 
   uses
     cutils,
-    symbase,symsym,symtable,pparautl;
+    symbase,symsym,symtable,pparautl,globtype;
 
 
   function create_outline_procdef(const basesymname: string; astruct: tabstractrecorddef; potype: tproctypeoption; resultdef: tdef): tprocdef;
@@ -72,6 +72,9 @@
         nested procvars modeswitch is active. We must be independent of this switch. }
       exclude(result.procoptions,po_delphi_nested_cc);
       result.proctypeoption:=potype;
+      { Also be independent of -CCxxx switch. }
+      result.proccalloption:=pocall_default;
+      include(result.procoptions,po_hascallingconvention);
       handle_calling_convention(result,hcc_default_actions_impl);
       sym:=cprocsym.create(basesymname+result.unique_id_str);
       st.insert(sym);

Cyrax

2019-01-30 00:58

reporter   ~0113725

Thanks for updated patch, Do-wan Kim!

Sven Barth

2019-02-10 12:27

manager   ~0114006

Thank you for the patch. Please test and close if okay

Issue History

Date Modified Username Field Change
2016-05-28 19:01 Max Nazhalov New Issue
2016-05-28 19:01 Max Nazhalov File Added: ie201201143_r33559.zip
2016-05-29 08:19 Sergei Gorelkin Note Added: 0092877
2016-05-29 08:20 Sergei Gorelkin File Added: 30205.patch
2016-05-29 08:51 Max Nazhalov Note Added: 0092878
2016-10-02 23:43 Jonas Maebe Relationship added child of 0028756
2019-01-21 22:43 Cyrax Note Added: 0113557
2019-01-21 23:46 Cyrax File Added: out01.txt
2019-01-21 23:51 Cyrax File Added: fpcdebug.zip
2019-01-21 23:51 Cyrax File Added: tree.zip
2019-01-26 07:51 Do-wan Kim Note Added: 0113628
2019-01-27 01:59 Do-wan Kim File Added: procdefutil.pas-30205.patch
2019-01-30 00:58 Cyrax Note Added: 0113725
2019-02-10 12:27 Sven Barth Fixed in Revision => 41277
2019-02-10 12:27 Sven Barth Note Added: 0114006
2019-02-10 12:27 Sven Barth Status new => resolved
2019-02-10 12:27 Sven Barth Fixed in Version => 3.3.1
2019-02-10 12:27 Sven Barth Resolution open => fixed
2019-02-10 12:27 Sven Barth Assigned To => Sven Barth