* * *

Author Topic: [Fixed] FPC 3.0.4 Compilation exception (fatal 1018)  (Read 4900 times)

jakubklos

  • New member
  • *
  • Posts: 11
[Fixed] FPC 3.0.4 Compilation exception (fatal 1018)
« on: April 08, 2018, 08:36:05 am »
When I build a project it all works. Then I make a small change and even revert the change and select to compile. The compilation is aborted because of the problem below.
(I used lazbuild from the command line to get the exception because Lazarus hides it)

It must be some bug in the FPC compiler but not sure how to deal with this and would like to help to get this resolved.

Free Pascal Compiler version 3.0.4 [2018/02/25] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
(1002) Target OS: Win32 for i386
(3104) Compiling SimpleObjectsTest.dpr
(3104) Compiling SimpleObjects.pas
C:\Repository\mail_server\Components\Lib\tests\SimpleObjectsTest\SimpleObjects.pas(207,9) Warning: (5043) Symbol "Resume" is deprecated
Fatal: (1018) Compilation aborted
An unhandled exception occurred at $0044EFB6:
EAccessViolation: Access violation
  $0044EFB6
  $004E7F50
  $004F8FB4
  $004F9C8B
  $004F9B19
  $0053DA3F
  $00433098
  $00534F48
  $0053CA4B
  $00540050
  $004330D7
  $00413A79

Error: C:\lazarus\fpc\3.0.4\bin\i386-win32\ppc386.exe returned an error exitcode
Error: (lazarus) Compile Project, Mode: Windows, Target: SimpleObjectsTest.exe: stopped with exit code 1
Error: (lazbuild) failed compiling of project C:\Repository\mail_server\Components\Lib\tests\SimpleObjectsTest\SimpleObjectsTest.lpi
« Last Edit: April 10, 2018, 02:17:30 pm by jakubklos »

Handoko

  • Hero Member
  • *****
  • Posts: 2434
  • My goal: build my own game engine using Lazarus
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #1 on: April 08, 2018, 09:17:51 am »
Hallo jakubklos,
Welcome to the  forum.

Simply showing your issue isn't very useful for us to be able to help you fixing the problem. You should provide more information like the source code or the steps to reproduce the issue, etc.

Have you tried to remove the lib folder? I sometimes get 'weird' compilation result but it can be solved if I delete the lib folder and recompile again.

jakubklos

  • New member
  • *
  • Posts: 11
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #2 on: April 08, 2018, 09:24:06 am »
Hi Handoko
than you for your response.

Deleting the lib folder helps of course because it is the same as building the project. That works but after a change (possible only a time stamp modification of one unit file) the compilation breaks.

It is a huge project so I cannot share it easily. I was mainly asking for some guidelines to how debug / troubleshoot this.
Currently I am thinking about compiling the compiler with debug information so I get the stack of the error with line numbers and function names.
Nothing else comes to my mind.

Thank you

Thaddy

  • Hero Member
  • *****
  • Posts: 6517
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #3 on: April 08, 2018, 11:45:08 am »
Which mode are you using? ObjFpc or Delphi mode?
I have seen this in more than one question and usually you need to change the mode (for that specific unit).
It often is caused by implicit procedural pointers (as in mode delphi) as opposed to explicit procedural pointers (that need @) in mode ObjFpc.

If you mix them up you'll get e.g. @@, a (pointer to a pointer to a reference)  instead, which does kaboom! a.k.a your 1018.
« Last Edit: April 08, 2018, 11:47:49 am by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

jakubklos

  • New member
  • *
  • Posts: 11
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #4 on: April 08, 2018, 12:35:48 pm »
I gave it some time and was able to filter all the required units from the big project to reproduce this issue.
It is only 3 units now. I am attaching the project.

Reproduction:

1. Open the lpi project in Lazarus
2. Open the TestUnit.pas
3. Compile
so far so good
4. Make a change in the TestUnit.pas (add something to fail a compilation like "aaaa"). Compile. It fails. Now revert the added text and compile again.
It should compile properly but does not. Instead if fails with the exception in my original post.

- If you comment out the TTestDataCollection definition in the TestUnit.pas it can compile without building
- If you make a change in the ListUnit (when the issue occurs) then again it can compile just fine because this unit gets recompiled

As you can see you cannot really use this in production because after any change you must rebuild the whole project.
Please, let me know what else to do

Thank you

WooBean

  • Jr. Member
  • **
  • Posts: 71
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #5 on: April 08, 2018, 02:46:28 pm »
Hi  jakubklos,

I have failed to reproduce the error (win32, FPC 3.0.4, Lazarus 1.8 ) - recompiling after changing a source works for me with no errors.

As the issue is very strange I can suggest 2 things - check your hdd and then check file attributes (suspected no write access for the current user for some existing binary files ".o", ".ppu").

WooBean
 
Win7/64, Lazarus 1.8 win64-win64, FPC 3.0.4

howardpc

  • Hero Member
  • *****
  • Posts: 2714
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #6 on: April 08, 2018, 03:46:20 pm »
@jakubklos

You do not specify a {$mode} in your project or units, which means they default to mode fpc (not objfpc, or delphi), which is probably not what you want.

Perhaps the compilation problem arises from a weakness in generics syntax  somewhere (this is just a guess) or your combination of generics and interfaces, which probes more recent compiler changes and either exposes a bug, or requires a stricter syntax adherence on your part. The compiler's inability to flag a more specific compilation error, or pin-point an offending source line is obviously unhelpful.
Perhaps to get line number information you will have to build the FPC RTL with debug information?
« Last Edit: April 08, 2018, 03:48:21 pm by howardpc »

wp

  • Hero Member
  • *****
  • Posts: 4800
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #7 on: April 08, 2018, 03:50:45 pm »
You do not specify a {$mode} in your project or units, which means they default to mode fpc (not objfpc, or delphi), which is probably not what you want.
Howard, is this really true? In the Lazarus project options ("Compiler options" > "Parsing") there's a setting for "Syntax mode (-M, {$MODE})". Isn't this the mode used when a mode is not specified for a unit?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Handoko

  • Hero Member
  • *****
  • Posts: 2434
  • My goal: build my own game engine using Lazarus
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #8 on: April 08, 2018, 03:59:58 pm »
Tested and followed what jakubklos said. It is 100% reproducible on Lazarus 1.8.0 FPC 3.04 64-bit Gtk2 Linux.

Using compile (Ctrl+F9) will get a compile-time error but no error if I use Build (Shift+F9).

Thaddy

  • Hero Member
  • *****
  • Posts: 6517
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #9 on: April 08, 2018, 04:02:52 pm »
@wp
Yes, but afaik only on full rebuilds ( -B in fpc ). There are a lot of users that assume a certain setting because mode and modeswtiches can be pretty confusing.
Even in the current codebase there are units that make assumptions,
Note in production you always do a full rebuild anyway.... (to OP)
« Last Edit: April 08, 2018, 04:06:08 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

wp

  • Hero Member
  • *****
  • Posts: 4800
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #10 on: April 08, 2018, 04:08:13 pm »
I don't have much experience with generics, but is your declaration of generic classes correct? You declare
Code: Pascal  [Select]
  1. type  
  2.   TNullable<T> = Class(TObject)
  3.     ...
  4.   end;
According to http://wiki.freepascal.org/Generics#Custom_Generic_Classes, shouldn't this be like this?
Code: Pascal  [Select]
  1. type
  2.   generic TList<T> = class
  3.     ...
  4.   end;
« Last Edit: April 08, 2018, 04:11:41 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

mse

  • Sr. Member
  • ****
  • Posts: 274
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #11 on: April 08, 2018, 04:17:53 pm »
It happens sometimes that FPC crashes without -B, we have to live with it. IIRC Free Pascal core members wrote that it is not fixable without a complete redesign of unit handling. Sometimes it is even necessary to delete all *.ppu and *.o files.

Thaddy

  • Hero Member
  • *****
  • Posts: 6517
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #12 on: April 08, 2018, 04:29:34 pm »
I don't have much experience with generics, but is your declaration of generic classes correct? You declare
Code: Pascal  [Select]
  1. type  
  2.   TNullable<T> = Class(TObject)
  3.     ...
  4.   end;
According to http://wiki.freepascal.org/Generics#Custom_Generic_Classes, shouldn't this be like this?
Code: Pascal  [Select]
  1. type
  2.   generic TList<T> = class
  3.     ...
  4.   end;

The first one is delphi mode, the second one is fpc mode. Both are legal. But NOT in the same unit.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

WooBean

  • Jr. Member
  • **
  • Posts: 71
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #13 on: April 08, 2018, 04:34:37 pm »
Tested and followed what jakubklos said. It is 100% reproducible on Lazarus 1.8.0 FPC 3.04 64-bit Gtk2 Linux.

Using compile (Ctrl+F9) will get a compile-time error but no error if I use Build (Shift+F9).

My previous post was based on "build" compilation, now I tested "compile" (Ctrl+F9) mode (win32, FPC 3.4, Lazarus 1.8, code parsing mode -MDelphi) and problem signalled by TS appeared for me too. The problem may be in FPC(/Lazarus) - changed source (even when the change is reverted) is badly treated by FPC in "compile" and "quick compile" compilation (file timestamps not properly maintaned?).

WooBean

Win7/64, Lazarus 1.8 win64-win64, FPC 3.0.4

Thaddy

  • Hero Member
  • *****
  • Posts: 6517
Re: FPC 3.0.4 Compilation exception (fatal 1018)
« Reply #14 on: April 08, 2018, 04:48:04 pm »
Tested and followed what jakubklos said. It is 100% reproducible on Lazarus 1.8.0 FPC 3.04 64-bit Gtk2 Linux.

Using compile (Ctrl+F9) will get a compile-time error but no error if I use Build (Shift+F9).

My previous post was based on "build" compilation, now I tested "compile" (Ctrl+F9) mode (win32, FPC 3.4, Lazarus 1.8, code parsing mode -MDelphi) and problem signalled by TS appeared for me too. The problem may be in FPC(/Lazarus) - changed source (even when the change is reverted) is badly treated by FPC in "compile" and "quick compile" compilation (file timestamps not properly maintaned?).

WooBean
No. It is just the unit concept that causes this and that is a feature. People coming from other languages are unfamiliar with this behavior, but it allows for (much!) faster compiles. Touched units are recompiled in any case, but related code in un-touched units may have to be recompiled as well. Usually it is caused by bad design but that is not always the case.
« Last Edit: April 08, 2018, 04:51:38 pm by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus