View Issue Details

IDProjectCategoryView StatusLast Update
0036559FPCCompilerpublic2020-01-24 18:30
ReporterPhoenix Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
PlatformIntel i7-6700HQ RAM8GBOSWindows Home 64bit 
Product Version3.0.4 
Summary0036559: source with "generic", it fails to compile after the first successfully
DescriptionThis is the error message when it fails (64bit -o1):

Hint: (11030) Start of reading config file C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.0.4 [2019/10/27] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(3104) Compiling unit2.pas
(3104) Compiling unit3.pas
C:\Users\Phoenix\Desktop\test generic\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $000000010003A13F:
EAccessViolation: Access violation
  $000000010003A13F
  $0000000100097E0C
  $000000010012D95A
  $0000000100023855
  $000000010012DC22
  $000000010017326A
  $0000000100173BBB
  $00000001001730FD
  $000000010003D01A
  $0000000100167CB7
  $000000010016712B
  $0000000100167A36
  $0000000100167343
  $0000000100167A36
  $0000000100171DE1
  $0000000100175EC2
  $000000010003D064

Error: C:\lazarus\fpc\3.0.4\bin\x86_64-win64\ppcx64.exe returned an error exitcode
Steps To Reproduce- open the lazarus project from the original folder
- from the menu: run -> compile
(result success: 167 lines compiled, 1.1 sec, 1693632 bytes code, 120100 bytes data)
- from the menu: run -> compile
(Fatal: Compilation aborted)

note: if I use "compile" it continues to fail always while if I use "build" the exe is created
Additional InformationI used: Laz. x86_64-win64-win32/win64 Date: 2019-12-12

I restarted the computer so that I had "clean" memory before doing the test

I have reduced the code to a minimum to reproduce it because the original source is huge. The only difference is that in the complete program the "build" also fails. The only way that allows me to be able to continue and avoid using TMySort inside TMyArray.

Thanks for your work!!
Tagsgenerics
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Phoenix

2020-01-11 23:24

reporter  

test generic.zip (130,869 bytes)

Cyrax

2020-01-12 00:00

reporter   ~0120346

Can you test if FPC trunk have a fix for this, please?

Bart Broersma

2020-01-12 14:22

reporter   ~0120359

Same error with fpc trunk (r43847):

I got a better backtrace though.

Hint: (11030) Start of reading config file C:\pp\bin\i386-win32\fpc.cfg
Hint: (11031) End of reading config file C:\pp\bin\i386-win32\fpc.cfg
Free Pascal Compiler version 3.3.1 [2020/01/03] for i386
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Win32 for i386
(3104) Compiling project1.lpr
(3104) Compiling unit2.pas
(3104) Compiling unit3.pas
c:\Users\Bart\LazarusProjecten\bugs\generics\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
c:\Users\Bart\LazarusProjecten\bugs\generics\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
unit2.pas(23) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $00422510:
EAccessViolation: Access violation
  $00422510 TFPHASHOBJECTLIST__FINDWITHHASH, of cclasses.pas
  $0043ED8F SEARCHSYM_WITH_FLAGS, line 3369 of symtable.pas
  $004A29EA ADD_GENERIC_DUMMYSYM, line 1503 of pgenutil.pas
  $00464850 TDEFAWARESYMTABLESTACK__ADD_HELPERS_AND_GENERICS, line 1658 of symdef.pas
  $00464AB8 TDEFAWARESYMTABLESTACK__PUSH, line 1749 of symdef.pas
  $005865A6 FINISH_UNIT, line 1482 of pmodules.pas
  $00585CB7 PROC_UNIT, line 1131 of pmodules.pas
  $00439874 COMPILE, line 401 of parser.pas
  $004C36B8 TPPUMODULE__LOADPPU, line 2185 of fppu.pas
  $004C2D92 TPPUMODULE__LOAD_USEDUNITS, line 1804 of fppu.pas
  $004C34D9 TPPUMODULE__LOADPPU, line 2130 of fppu.pas
  $004C2F32 TPPUMODULE__LOAD_USEDUNITS, line 1866 of fppu.pas
  $004C34D9 TPPUMODULE__LOADPPU, line 2130 of fppu.pas
  $00584853 LOADUNITS, line 518 of pmodules.pas
  $00587981 PROC_PROGRAM, line 2138 of pmodules.pas
  $004398C1 COMPILE, line 409 of parser.pas
  $00416605 COMPILE, line 278 of compiler.pas

Error: C:\pp\bin\i386-win32\ppc386.exe returned an error exitcode

Phoenix

2020-01-13 22:39

reporter   ~0120415

Thanks Bart Broersma for the confirmation
I also confirm that the problem persists:

Hint: (11030) Start of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.3.1-r43916 [2020/01/12] for x86_64
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(3104) Compiling unit2.pas
C:\Users\Phoenix\Desktop\test generic\unit2.pas(21,65382) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $000000010003DFD4:
EAccessViolation: Access violation
  $000000010003DFD4
  $00000001000DEEE1
  $00000001000DF78A
  $00000001000DF0A3
  $00000001000DF78A
  $00000001001BDA41
  $00000001001C1271
  $000000010003F721
  $0000000100017E49
  $0000000100001A5D
  $0000000100001A76
  $0000000100014680
  $0000000100001840
  $00007FF9D2CE7BD4
  $00007FF9D354CED1

Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode

Phoenix

2020-01-18 12:38

reporter   ~0120510

There is probably a continuous memory violation (at every compilation). In the complete source, even just adding new classes with "generics" (and using them in other units) leads to failed compilations for no apparent reason (I think it is linked to the same problem even if I can't create a further special test) . I think the report provided by @Bart is quite informative (I tried but I don't know how to provide such a detailed report). I'd like to, if possible, to be able to use the next version of the compiler with more security.

Bart Broersma

2020-01-18 16:09

reporter   ~0120514

Build fpc with OPT="-g -gl", so you get backtraces from the compiler and RTL.

Sven Barth

2020-01-18 23:14

manager   ~0120524

Please provide an example that does not depend on the LCL.

Phoenix

2020-01-18 23:47

reporter   ~0120525

@Sven Barth
ok i will try.
I had already done tests today with the example provided but I don't know if it can be useful

Thanks @Bart
I have never compiled fpc and the "build 11/01" that I use I found it here http://projects.martoks-place.de/lazarus/ (google drive)
But i used Lazarus 2.0.6 replacing the dir fpc (3.0.4 -> 3.3.1 copying the configuration file)
later I downloaded "fpc.zip 12/01" from the compiler site and compiled "ppcx64.lpi".
I don't know if it's ok but I just copied the resulting "pp.exe" as "ppcx86.exe" into the "bin".
I admit I have not done research but I hope it is not a total failure .. it seems to work somehow..


This is the result for the test available:

- first successful compilation

Hint: (11030) Start of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.3.1 [2020/01/18] for x86_64
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(3104) Compiling unit1.pas
(3104) Compiling my_array.pas
(3104) Compiling my_sort.pas
C:\Users\Phoenix\Desktop\test generic\my_sort.pas(8,10) Note: (5071) Private type "TMySort$1.T" never used
(3104) Compiling unit2.pas
(3104) Compiling unit3.pas
(3104) Compiling unit2.pas
C:\Users\Phoenix\Desktop\test generic\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
C:\Users\Phoenix\Desktop\test generic\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
C:\Users\Phoenix\Desktop\test generic\unit1.pas(43,2) Note: (5025) Local variable "my" not used
C:\Users\Phoenix\Desktop\test generic\unit1.pas(18,32) Hint: (5024) Parameter "Sender" not used
C:\Users\Phoenix\Desktop\test generic\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
C:\Users\Phoenix\Desktop\test generic\my_sort.pas(10,2) Note: (5071) Private type "TMySort$1<SYSTEM.LongInt>.T" never used
C:\Users\Phoenix\Desktop\test generic\project1.lpr(10,17) Hint: (5023) Unit "Unit3" not used in project1
C:\Users\Phoenix\Desktop\test generic\project1.lpr(10,24) Hint: (5023) Unit "unit2" not used in project1
(9022) Compiling resource C:\Users\Phoenix\Desktop\test generic\lib\x86_64-win64\project1.obj
(9015) Linking C:\Users\Phoenix\Desktop\test generic\project1.exe
(1008) 167 lines compiled, 1.5 sec, 1690048 bytes code, 126868 bytes data
(1022) 8 hint(s) issued
(1023) 3 note(s) issued

- second blocked by an error:

Hint: (11030) Start of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.3.1 [2020/01/18] for x86_64
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(3104) Compiling unit2.pas
(3104) Compiling unit3.pas
C:\Users\Phoenix\Desktop\test generic\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
C:\Users\Phoenix\Desktop\test generic\unit3.pas(10,14) Error: (5005) Forward declaration not solved "test;"
unit2.pas(23) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode

- third definitive failure

Hint: (11030) Start of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.3.1 [2020/01/18] for x86_64
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(3104) Compiling unit2.pas
C:\Users\Phoenix\Desktop\test generic\unit2.pas(21,65382) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $0000000100044846:
EAccessViolation: Access violation
  $0000000100044846 ADDDEPENDENCY, line 941 of fmodule.pas
  $000000010010650A LOAD_USEDUNITS, line 1809 of fppu.pas
  $00000001001070A3 LOADPPU, line 2130 of fppu.pas
  $000000010010676B LOAD_USEDUNITS, line 1866 of fppu.pas
  $00000001001070A3 LOADPPU, line 2130 of fppu.pas
  $00000001002050FE LOADUNITS, line 518 of pmodules.pas
  $0000000100208EFD PROC_PROGRAM, line 2138 of pmodules.pas
  $00000001000461F1 COMPILE, line 409 of parser.pas
  $000000010001ABB9 COMPILE, line 278 of compiler.pas
  $0000000100001A81 main, line 278 of pp.pas
  $0000000100001AA6
  $0000000100014A40
  $0000000100001860
  $00007FF9006F7BD4
  $00007FF901C8CED1

Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode



This I get when (in the complete source) the first "build" fails (it is practically impossible to compile if I use the class for the sort inside the class of the list):

Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $0000000100044846:
EAccessViolation: Access violation
  $0000000100044846 ADDDEPENDENCY, line 941 of fmodule.pas
  $0000000100205126 LOADUNITS, line 523 of pmodules.pas
  $000000010020638F PROC_UNIT, line 975 of pmodules.pas
  $00000001000461A5 COMPILE, line 401 of parser.pas
  $0000000100107380 LOADPPU, line 2185 of fppu.pas
  $00000001002050FE LOADUNITS, line 518 of pmodules.pas
  $000000010020638F PROC_UNIT, line 975 of pmodules.pas
  $00000001000461A5 COMPILE, line 401 of parser.pas
  $0000000100107380 LOADPPU, line 2185 of fppu.pas
  $00000001002050FE LOADUNITS, line 518 of pmodules.pas
  $000000010020674F PROC_UNIT, line 1070 of pmodules.pas
  $00000001000461A5 COMPILE, line 401 of parser.pas
  $0000000100107380 LOADPPU, line 2185 of fppu.pas
  $00000001002050FE LOADUNITS, line 518 of pmodules.pas
  $000000010020638F PROC_UNIT, line 975 of pmodules.pas
  $00000001000461A5 COMPILE, line 401 of parser.pas
  $0000000100107380 LOADPPU, line 2185 of fppu.pas

Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode

After the failed build I just go to comment on a line and run "compile"
..
 TSArray<T> = class
  type
   //TSArraySort = TSSort<T>;
   ..
This happens when the memory is probably already "compromised".

Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $000000010004DC29:
EAccessViolation: Access violation
  $000000010004DC29 SEARCHSYM_IN_MODULE, line 3530 of symtable.pas
  $00000001001AC82F TRY_CONSUME_UNITSYM, line 395 of pbase.pas
  $00000001001CB3C5 FACTOR_READ_ID, line 2910 of pexpr.pas
  $00000001001C93F3 FACTOR, line 3497 of pexpr.pas
  $00000001001CC7F7 SUB_EXPR, line 4354 of pexpr.pas
  $00000001001CC830 SUB_EXPR, line 4359 of pexpr.pas
  $00000001001CC830 SUB_EXPR, line 4359 of pexpr.pas
  $00000001001CC830 SUB_EXPR, line 4359 of pexpr.pas
  $00000001001CDAFA COMP_EXPR, line 4578 of pexpr.pas
  $00000001001C6AAA POSTFIXOPERATORS, line 2163 of pexpr.pas
  $00000001001C963E FACTOR, line 3538 of pexpr.pas
  $00000001001CC7F7 SUB_EXPR, line 4354 of pexpr.pas
  $00000001001CC830 SUB_EXPR, line 4359 of pexpr.pas
  $00000001001CC830 SUB_EXPR, line 4359 of pexpr.pas
  $00000001001CC830 SUB_EXPR, line 4359 of pexpr.pas
  $00000001001CDC91 EXPR, line 4618 of pexpr.pas
  $00000001001AFC17 STATEMENT, line 1238 of pstatmnt.pas

Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode

I don't remember how this looked. (perhaps after combining some "generics" classes into a single unit and then modifying the "links")

Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $0000000100080E95:
EAccessViolation: Access violation
  $0000000100080E95 line 1749 of symdef.pas
  $00000001000D67F1 line 1587 of pgenutil.pas
  $00000001000D44B1 line 895 of pgenutil.pas
  $00000001001CBC23 line 1528 of pexpr.pas
  $00000001001D23BE line 3210 of pexpr.pas
  $00000001001CF82F line 3497 of pexpr.pas
  $00000001001D2D4A line 4354 of pexpr.pas
  $00000001001D2D7B line 4359 of pexpr.pas
  $00000001001D2D7B line 4359 of pexpr.pas
  $00000001001D2D7B line 4359 of pexpr.pas
  $00000001001D3F24 line 4578 of pexpr.pas
  $00000001001DE306 line 1106 of ptype.pas
  $00000001001DD251 line 1964 of ptype.pas
  $00000001001B7BCA line 878 of pdecl.pas
  $00000001001C69E1 line 1337 of pdecobj.pas
  $00000001001C7803 line 1619 of pdecobj.pas
  $00000001001DCDCF line 1871 of ptype.pas

Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode

Phoenix

2020-01-19 00:02

reporter   ~0120526

@PascalDragon
Thanks for your attention to the problem
I attach the test

Trying the first compilation is always ok while the second one fails:

Hint: (11030) Start of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file C:\lazarus\fpc\3.3.1\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.3.1 [2020/01/18] for x86_64
Copyright (c) 1993-2019 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling project1.lpr
(3104) Compiling unit2.pas
(3104) Compiling unit3.pas
C:\Users\Phoenix\Desktop\test_generic_no_lcl\unit3.pas(20,11) Hint: (5028) Local type "MyNode" is not used
C:\Users\Phoenix\Desktop\test_generic_no_lcl\unit2.pas(21,4) Error: (1026) Compilation raised exception internally
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $000000010004278E:
EAccessViolation: Access violation
  $000000010004278E FIND_MODULE_FROM_SYMTABLE, line 320 of fmodule.pas
  $00000001000D629F SPECIALIZATION_INIT, line 1560 of pgenutil.pas
  $00000001000D6AB1 GENERATE_SPECIALIZATION_PROCS, line 1743 of pgenutil.pas
  $0000000100206C63 FINISH_UNIT, line 1206 of pmodules.pas
  $00000001002075E7 FINISH_UNIT, line 1482 of pmodules.pas
  $0000000100206B22 PROC_UNIT, line 1131 of pmodules.pas
  $00000001000461A5 COMPILE, line 401 of parser.pas
  $0000000100107380 LOADPPU, line 2185 of fppu.pas
  $00000001001064EB LOAD_USEDUNITS, line 1804 of fppu.pas
  $00000001001070A3 LOADPPU, line 2130 of fppu.pas
  $00000001002050FE LOADUNITS, line 518 of pmodules.pas
  $0000000100208EFD PROC_PROGRAM, line 2138 of pmodules.pas
  $00000001000461F1 COMPILE, line 409 of parser.pas
  $000000010001ABB9 COMPILE, line 278 of compiler.pas
  $0000000100001A81 main, line 278 of pp.pas
  $0000000100001AA6
  $0000000100014A40

Error: C:\lazarus\fpc\3.3.1\bin\x86_64-win64\ppcx64.exe returned an error exitcode

Sven Barth

2020-01-21 22:51

manager   ~0120665

Thanks for the updated test. This is a complex one, don't know when I'll be able to solve this. As a workaround you need to get rid of the cycle between Unit2 and Unit3 (in the example; don't know where it is in your real usecase).

Phoenix

2020-01-22 09:38

reporter   ~0120668

I understand In fact I looked at the various problems on generics and from what I saw it is not something easy to solve. I had just started using them (and I also enjoyed it). So these days I have grouped all the classes that use it by accessing it are from one unit. I noticed an improvement only that when working on these units I have to use only build and do not compile otherwise the compilation hangs in pointless (but always the same) points. Also not using the build I noticed that you risk that the last changes made to the code have not actually been compiled in the resulting exe. A period I also had an "internal error 200510011" but it disappeared into thin air after unspecified changes (first uses in 3.0.4). I was thinking if putting these units in a package could possibly avoid the problem (if I don't go to edit them)?
But maybe, until these units are not modified or I call a "forced" build I get the same result without separating the source.
The only thing that worries me are memory violations. Ok when I work on them at this point I expect it. But, once the exe is created is it safe from this point of view (for example a build successful after a compilation stopped by the problem)?

 Thanks

P.S. Sorry for my English, this time I used the Google translator a lot.

Sven Barth

2020-01-24 17:06

manager   ~0120714

The problem here is PPU loading in the situation that you have not only a cycle between units, but also between generics (in your example TData<> in one unit uses TNode<> in another which again uses TData<> in the first unit). So for now it would be best to get rid of this cycle between the generics (e.g. by using a generic base class or something like that for one of them).

Otherwise you need to do clean rebuilds, then the PPU loading at least for those units is not involved and it will work correctly.

Phoenix

2020-01-24 18:30

reporter   ~0120717

Ok, thanks for the info

Issue History

Date Modified Username Field Change
2020-01-11 23:24 Phoenix New Issue
2020-01-11 23:24 Phoenix File Added: test generic.zip
2020-01-12 00:00 Cyrax Note Added: 0120346
2020-01-12 14:22 Bart Broersma Note Added: 0120359
2020-01-12 21:50 Cyrax Tag Attached: generics
2020-01-13 22:39 Phoenix Note Added: 0120415
2020-01-18 12:38 Phoenix Note Added: 0120510
2020-01-18 16:09 Bart Broersma Note Added: 0120514
2020-01-18 23:14 Sven Barth Assigned To => Sven Barth
2020-01-18 23:14 Sven Barth Status new => feedback
2020-01-18 23:14 Sven Barth FPCTarget => -
2020-01-18 23:14 Sven Barth Note Added: 0120524
2020-01-18 23:47 Phoenix Note Added: 0120525
2020-01-18 23:47 Phoenix Status feedback => assigned
2020-01-19 00:02 Phoenix File Added: test_generic_no_lcl.zip
2020-01-19 00:02 Phoenix Note Added: 0120526
2020-01-21 22:51 Sven Barth Note Added: 0120665
2020-01-22 09:38 Phoenix Note Added: 0120668
2020-01-24 17:06 Sven Barth Note Added: 0120714
2020-01-24 18:30 Phoenix Note Added: 0120717