Recent

Author Topic: Error: Compilation raised exception internally  (Read 598 times)

janasoft

  • Jr. Member
  • **
  • Posts: 51
Error: Compilation raised exception internally
« on: April 16, 2026, 02:29:19 pm »
Hello.
I'm developing a personal framework that makes extensive use of generics.
The application already has a large number of units and is quite complex.
Until now, I've encountered the problem that, in some cases, when pressing CTRL+F9, the system wouldn't recognize that a file hadn't been modified and would force me to perform a full build (SHIFT+F9). It's a bit annoying, but manageable.
For the past few days, without having modified the IDE environment and, I believe, without having substantially modified the framework code, I've been experiencing a problem: whenever I press CTRL+F9, the compilation process stops.
The problem occurs in exactly the same way in Linux (Lazarus 4.7 (rev lazarus_4_6-39-g2ad6dffe3e) FPC 3.2.2 x86_64-linux-gtk2) and in Windows (Lazarus 4.4 (rev lazarus_4_4) FPC 3.2.2 x86_64-win64-win32/win64)
In linux I get these errors:
Code: Pascal  [Select][+][-]
  1. Error: An unhandled exception occurred at $00000000004643CC:
  2. Debug:   $00000000004643CC
  3. presenter.ciudades.pas(17,4) Error: Compilation raised exception internally[/pre][/pre]

In Windows I get only this:
Code: Pascal  [Select][+][-]
  1. presenter.ciudades.pas(17,4) Error: Compilation raised exception internally

If I run a build (SHIFT+F9), the application compiles correctly.

The code in the unit where the error occurs is very simple. It's a definition of a class specialization that has no associated code, although I suspect the cause of the error might lie elsewhere.
Code: Pascal  [Select][+][-]
  1. {$mode ObjFPC}{$H+}
  2. interface
  3. uses
  4.   Classes, SysUtils, entity.ciudad, presenter.entity_view;
  5. type
  6.   { TCiudadPresenter }    // Error references this line
  7.    TCiudadPresenter = class(specialize TEntityViewPresenter<TCiudad>)
  8.   end;
  9. implementation
  10. { TCiudadPresenter }
  11. end.
  12.  
I've seen on the forum that similar problems have already arisen when using generics. I've configured the compiler options as indicated in this link, but the result is the same.
I've also completely removed the lib folder and performed a clean build, but the problem persists exactly the same.

Any ideas?

Khrys

  • Sr. Member
  • ****
  • Posts: 434
Re: Error: Compilation raised exception internally
« Reply #1 on: April 17, 2026, 06:22:32 am »
Unhandled exceptions (and internal errors) are compiler bugs - they should never happen, and any occurrences should be reported.
With that being said, there are roughly 20,000 (!) commits between 3.2.2 and trunk as of today, and there's a good chance that this bug has been fixed already.

Here's how I would proceed if I were you:
  • Build FPC trunk with debug information enabled
  • Attempt to compile the framework using said trunk compiler and hope it succeeds
  • On failure, look at the backtrace (possible because of debug info) and either try to understand the cause of the error enough to work around it, or simply report it as an issue in the bug tracker

janasoft

  • Jr. Member
  • **
  • Posts: 51
Re: Error: Compilation raised exception internally
« Reply #2 on: April 17, 2026, 01:18:59 pm »
Thank you for your answer Khrys.
I will try to do what you suggest and see the results.
Anyway I have backups of previous versions, and it seems the problem didn't occur in the second-to-last version.
I'm going to try to analyze what I've changed since that version.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12345
  • Debugger - SynEdit - and more
    • wiki
Re: Error: Compilation raised exception internally
« Reply #3 on: April 17, 2026, 01:44:03 pm »
Actually - it seems you are on Windows - you can try Lazarus 4.6 (or 4.4) with the Rc1 of FPC 3.2.4

https://sourceforge.net/projects/lazarus-snapshots/files/Window%2064/2026-02%20Lazarus%204.6%20with%20FPC%203.2.4-RC1%20%28d3a5f442eeff%29/

There are also builds for 32 bit, and for Lazarus 4.4.

If you are lucky, its fixed in there.
If not, you may still have to either test fpc 3.3.1 (aka trunk).

Or you try commenting some code in the unit that causes the crash.
If you can find out what causes the crash, then you can maybe rewrite it, and it will work.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12842
  • FPC developer.
Re: Error: Compilation raised exception internally
« Reply #4 on: April 17, 2026, 02:44:06 pm »

Any ideas?

In such cases try to define the specialisation first as type, and then inherit from it.

Code: Pascal  [Select][+][-]
  1.    TSomeCityBasetype = specialize TEntityViewPresenter<TCiudad>;
  2.   TCiudadPresenter = class(TSomeCityBasetype)
  3.                                           ..
  4.  

I.e. do in multiple steps if possible.

janasoft

  • Jr. Member
  • **
  • Posts: 51
Re: Error: Compilation raised exception internally
« Reply #5 on: April 18, 2026, 06:15:16 pm »
In such cases try to define the specialisation first as type, and then inherit from it.

Code: Pascal  [Select][+][-]
  1.    TSomeCityBasetype = specialize TEntityViewPresenter<TCiudad>;
  2.   TCiudadPresenter = class(TSomeCityBasetype)
  3.                                           ..
  4.  

I.e. do in multiple steps if possible.
I already tried this, but it didn't work either.

In any case, thank you very much.

janasoft

  • Jr. Member
  • **
  • Posts: 51
Re: Error: Compilation raised exception internally
« Reply #6 on: April 18, 2026, 06:21:54 pm »
Actually - it seems you are on Windows - you can try Lazarus 4.6 (or 4.4) with the Rc1 of FPC 3.2.4
The problem occurs in both Windows and Linux, so it doesn't appear to be a platform issue.
As soon as I can, I'll test it with the version you mentioned.
I'm also going to test previous versions of my code to see if I can find where the error starts.
Thank you for your ideas

cdbc

  • Hero Member
  • *****
  • Posts: 2772
    • http://www.cdbc.dk
Re: Error: Compilation raised exception internally
« Reply #7 on: April 18, 2026, 07:02:50 pm »
Hi
I've just recently had a similar "Error: Compilation raised exception internally" error...  %)
Upon investigation, it turned out, that I was registering a TxxxStyleType with the fpgStyleManager TWICE WITH THE SAME NAME 'xxxStyle', so the compiler got seriously confused  :P
...Since your framework looks somewhat familiar to me, I'll bet, you've maybe overlooked some of the e.g.: /RegisterTransaction({name},{class})/ that deviously hide in the initialization-sections of your units... 8-)
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

 

TinyPortal © 2005-2018