Recent

Author Topic: Fatal: Internal error 200305108  (Read 7883 times)

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Fatal: Internal error 200305108
« on: February 11, 2024, 08:10:56 pm »
I tried to compile the source code below, but I fail with the Subject Fatal Message:
So, how can I use Q_NULLPTR correctly ?
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. unit qObject;
  3.  
  4. interface
  5. function Q_NULLPTR: Pointer;
  6.  
  7. type
  8.   QObject = class
  9.   private
  10.   public
  11.     constructor Create(parent: QObject); overload;
  12.     constructor Create; overload;
  13.     destructor Destroy;
  14.   end;
  15.  
  16. implementation
  17.  
  18. function Q_NULLPTR: Pointer;
  19. begin
  20.   result := Pointer(0);
  21. end;
  22.  
  23. constructor QObject.Create(parent: QObject);
  24. begin
  25.   parent := Q_NULLPTR;
  26. end;
  27.  
  28. constructor QObject.Create;
  29. begin
  30. end;
  31.  
  32. destructor QObject.Destroy;
  33. begin
  34. end;
  35.  
  36. initialization
  37.  
  38. finalization
  39.  
  40. end.
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

bytebites

  • Hero Member
  • *****
  • Posts: 794
Re: Fatal: Internal error 200305108
« Reply #1 on: February 11, 2024, 08:51:54 pm »
Code: Pascal  [Select][+][-]
  1. parent := nil;

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: Fatal: Internal error 200305108
« Reply #2 on: February 11, 2024, 08:56:43 pm »
ok thanks.
can I not use a custom "nil" type ?
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

Eugene Loza

  • Hero Member
  • *****
  • Posts: 729
    • My games in Pascal
Re: Fatal: Internal error 200305108
« Reply #3 on: February 11, 2024, 08:59:48 pm »
While the code above indeed has a lot of problems - and you will need to fix it to make do something meaningful, note that "Internal Error" means error not on your side, but a problem on compiler side. However, I've tried to reproduce it in the latest FPC trunk version and I don't get any Internal Error - the code compiles for me with fair warnings.

One of the simplest things to try "Run > Clean up and Build". If that doesn't work, try upgrading FPC version (e.g. through FPCUpDeluxe), maybe the issue has already been resolved.
My FOSS games in FreePascal&CastleGameEngine: https://decoherence.itch.io/ (Sources: https://gitlab.com/EugeneLoza)

jamie

  • Hero Member
  • *****
  • Posts: 7842
Re: Fatal: Internal error 200305108
« Reply #4 on: February 11, 2024, 09:30:33 pm »
using a NIL instead does not work?

I tried the code here,  I have no errors. on 3.0.4 or 3.2.2
The only true wisdom is knowing you know nothing

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: Fatal: Internal error 200305108
« Reply #5 on: February 11, 2024, 09:41:32 pm »
by using the following source code:
Note: The filename is Qt.qObject.pas !
Code: Pascal  [Select][+][-]
  1. // ---------------------------------------------------------------------------
  2. // File:   filter.spec - executable specified stuff
  3. // Author: Jens Kallup - paule32
  4. //
  5. // Rights: (c) 2024 by kallup non-profit software
  6. //         all rights reserved
  7. //
  8. // only for education, and for non-profit usage !!!
  9. // commercial use ist not allowed.
  10. // ---------------------------------------------------------------------------
  11. {$mode delphi}
  12. unit Qt.qObject;
  13.  
  14. interface
  15.  
  16. type
  17.   QCustomQObject = class
  18.   public
  19.     constructor Create;
  20.     destructor Destroy;
  21.   end;
  22.  
  23.   QObject = class
  24.   private
  25.   public
  26.     constructor Create(parent: QCustomQObject = nil);
  27.     destructor Destroy;
  28.   end;
  29.  
  30. implementation
  31.  
  32. { QCustomQObject }
  33. constructor QCustomQObject.Create;
  34. begin
  35. end;
  36. destructor QCustomQObject.Destroy;
  37. begin
  38. end;
  39.  
  40. { QObject }
  41. constructor QObject.Create(parent: QObject);
  42. begin
  43. end;
  44. destructor QObject.Destroy;
  45. begin
  46. end;
  47.  
  48. initialization
  49.  
  50. finalization
  51.  
  52. end.

I get:

Code: [Select]
E:\Projekte\fpc-qt\src>C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\fpc.exe -FE./units/fpc-qt  -Twin64 -Mdelphi -dwindows -dwin64
-b- -Sg -Sm -O2 -Os -Fu./units -vl    -Fu./units              -Fu./units/rtl          -Fu./sources/fpc-sys   -Fu./sources/fpc-rtl ./sources/fpc-qt/
Qt.qObject.pas
Free Pascal Compiler version 3.2.2 [2022/09/24] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling .\sources\fpc-qt\Qt.qObject.pas
2 200/1.280 Kb Used
Qt.qObject.pas(27,1) Fatal: Internal error 200305108
Fatal: Compilation aborted
Error: C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\ppcx64.exe returned an error exitcode
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

bytebites

  • Hero Member
  • *****
  • Posts: 794
Re: Fatal: Internal error 200305108
« Reply #6 on: February 11, 2024, 09:49:26 pm »
Line 41
Quote
Error: Function header doesn't match any method of this class "constructor Create(QObject);"

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: Fatal: Internal error 200305108
« Reply #7 on: February 11, 2024, 10:02:14 pm »
this does not change the Problem
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Fatal: Internal error 200305108
« Reply #8 on: February 11, 2024, 10:14:13 pm »
this does not change the Problem
It actually does.

Code: Pascal  [Select][+][-]
  1. program sausage;
  2.     // ---------------------------------------------------------------------------
  3.     // File:   filter.spec - executable specified stuff
  4.     // Author: Jens Kallup - paule32
  5.     //
  6.     // Rights: (c) 2024 by kallup non-profit software
  7.     //         all rights reserved
  8.     //
  9.     // only for education, and for non-profit usage !!!
  10.     // commercial use ist not allowed.
  11.     // ---------------------------------------------------------------------------
  12.     {$mode delphi}
  13. type
  14.   QCustomQObject = class
  15.    public
  16.     constructor Create;
  17.     destructor Destroy; override;
  18.    end;
  19.  
  20.    QObject = class
  21.     private
  22.     public
  23.       constructor Create(parent: QCustomQObject = nil);
  24.       destructor Destroy; override;
  25.    end;
  26.  
  27. { QCustomQObject }
  28. constructor QCustomQObject.Create;
  29. begin
  30. end;
  31.  
  32. destructor QCustomQObject.Destroy;
  33. begin
  34. end;
  35.  
  36. { QObject }
  37. constructor QObject.Create(parent: QCustomQObject = nil);  // <---- must match header
  38. begin
  39. end;
  40.  
  41. destructor QObject.Destroy;
  42. begin
  43. end;
  44.  
  45. begin
  46. end.
  47.  
Today is tomorrow's yesterday.

bytebites

  • Hero Member
  • *****
  • Posts: 794
Re: Fatal: Internal error 200305108
« Reply #9 on: February 11, 2024, 10:16:08 pm »
Override destructor

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: Fatal: Internal error 200305108
« Reply #10 on: February 11, 2024, 10:57:39 pm »
with:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. unit uq_Object;
  3.  
  4. interface
  5.  
  6. type
  7.   QObject = class
  8.   public
  9.     constructor Create(p: QObject);
  10.     destructor Destroy; override;
  11.   end;
  12.  
  13. implementation
  14.  
  15. constructor QObject.Create(p: QObject);
  16. begin
  17. end;
  18. destructor QObject.Destroy;
  19. begin
  20. end;
  21.  
  22. end.
I get;
Code: [Select]
E:\Projekte\fpc-qt\src>C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\fpc.exe -FE./tests/units -Twin64 -Mdelphi -dwindows -dwin64 -b- -Sg -Sm -O2 -Os -vl         -Fu./units              -Fu./units/rtl          -Fu./sources/fpc-sys    -Fu./sources/fpc-rtl    -Fu./sources/fpc-qt -Anasmwin64 -al -XMmainCRTstartup ./sources/fpc-test/test1.pas
Free Pascal Compiler version 3.2.2 [2022/09/24] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling .\sources\fpc-test\test1.pas
2 203/1.280 Kb Used
Compiling .\sources\fpc-qt\uq_Object.pas
uq_Object.pas(10,16) Error: There is no method in an ancestor class to be overridden: "destructor Destroy;"
uq_Object.pas(13,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\ppcx64.exe returned an error exitcode

with:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. unit uq_Object;
  3.  
  4. interface
  5.  
  6. type
  7.   QObject = class
  8.   public
  9.     constructor Create(p: QObject);
  10.     destructor Destroy;
  11.   end;
  12.  
  13. implementation
  14.  
  15. constructor QObject.Create(p: QObject);
  16. begin
  17. end;
  18. destructor QObject.Destroy;
  19. begin
  20. end;
  21.  
  22. end.
  23.  
I get:
Code: [Select]
E:\Projekte\fpc-qt\src>C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\fpc.exe -FE./tests/units -Twin64 -Mdelphi -dwindows -dwin64 -b- -Sg -Sm -O2 -Os -vl         -Fu./units              -Fu./units/rtl          -Fu./sources/fpc-sys    -Fu./sources/fpc-rtl    -Fu./sources/fpc-qt -Anasmwin64 -al -XMmainCRTstartup ./sources/fpc-test/test1.pas
Free Pascal Compiler version 3.2.2 [2022/09/24] for x86_64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling .\sources\fpc-test\test1.pas
2 203/1.280 Kb Used
Compiling .\sources\fpc-qt\uq_Object.pas
uq_Object.pas(16,1) Fatal: Internal error 200305108
Fatal: Compilation aborted
Error: C:\lazarus\x86_64\fpc\3.2.2\bin\x86_64-win64\ppcx64.exe returned an error exitcode
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Fatal: Internal error 200305108
« Reply #11 on: February 11, 2024, 11:05:09 pm »
Could you please start with removing the ubiquitous command line options ? e.g. how do you actually want to compile, mode TP or mode Delphi ? -Sg is already default for mode TP and mode Delphi etc. etc.

Also the use of nasm is listed as experimental.

I can not reproduce any of your errors with 3.2.2 at Linux 64 bit  :-\

But then, you are not exactly using 3.2.2, or are you ?
« Last Edit: February 11, 2024, 11:25:04 pm by TRon »
Today is tomorrow's yesterday.

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: Fatal: Internal error 200305108
« Reply #12 on: February 12, 2024, 07:09:44 am »
I tackle out some Tricks, but I am not fully satisfied.
You can follow the process at my https://github.com/paule32/Qt_FPC account.
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

Thaddy

  • Hero Member
  • *****
  • Posts: 19449
  • Glad to be alive.
Re: Fatal: Internal error 200305108
« Reply #13 on: February 12, 2024, 08:13:21 am »
Some remarks on the original. Some remarks were missing:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}
  2. unit qObject;
  3.  
  4. interface
  5. function Q_NULLPTR: Pointer;inline;
  6.  
  7. type
  8.   QObject = class
  9.   private
  10.   public
  11.     { if this constructor does not exist in ancestor
  12.       declare it as virtual, not overload, not override, not static }
  13.     constructor Create(parent: QObject); virtual;
  14.     { removed the static constructor it is called anyway
  15.       in the virtual constructor }
  16.     { removed empty destructor }
  17.   end;
  18.  
  19. implementation
  20. { inline to remove call overhead }
  21. function Q_NULLPTR: Pointer;inline;
  22. begin
  23.   result := Pointer(0);
  24. end;
  25.  
  26. constructor QObject.Create(parent: QObject);
  27. begin
  28.   { call the static constructor first }
  29.   inherited create;
  30.   { this is of little value if parent is not var or out.
  31.     and in that case there is more complexity to handle
  32.     the parent destruction to avoid leaks and crashes.
  33.     In other words, as is, it is local to this class }
  34.   parent := nil; { or your Q_NULLPTR, does the same if inlined }
  35. end;
  36.  
  37. end.

Note that your unit suffers from everything I corrected above:
https://github.com/paule32/Qt_FPC/blob/main/src/sources/fpc-qt/Qt_Object.pas

TIP you may want to introduce a parent field in the class. That will make more sense. You can then handle the parent as nil for the benefit of the class' operations and its children. I would think twice to set the class parent to nil globally, which happens with var or out. That means it affects all other code as well and is not trivial.
Code: Pascal  [Select][+][-]
  1. private
  2.    FParent:QObject ;
  3. public
  4.   property Parent:QObject read FParent;
  5. ....]
Then it makes sense: children can be tested for parent and only your root QObject  has no parent. You need to set FParent in the constructor, not parent and override the constructor at least once in children to set the correct parent. At least once because the first overridden constructor will always set a valid parent.  I will add a suggested example:
« Last Edit: February 12, 2024, 09:21:22 am by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

Thaddy

  • Hero Member
  • *****
  • Posts: 19449
  • Glad to be alive.
Re: Fatal: Internal error 200305108
« Reply #14 on: February 12, 2024, 09:51:56 am »
Suggested example:
Code: Pascal  [Select][+][-]
  1. {$mode delphi}{ or objfpc }
  2. unit Qt_Object;
  3.  
  4. interface
  5.  
  6. type
  7.   QObject = class
  8.   strict protected
  9.     { keeps access in derived classes }
  10.     FParent:QObject;
  11.   public
  12.     { if this constructor does not exist in ancestor
  13.       declare it as virtual, not overload, not override }
  14.     constructor Create(aParent: QObject); virtual;  
  15.     { Do NEVER introduce static destructors , Destructors are virtual }
  16.      // NO static destructors please....., that is an error
  17.  
  18.     { property is readonly, but FParent is protected
  19.       so can be set in children's constructors }
  20.     property Parent:QObject read FParent;
  21.   end;
  22.  
  23.   { example class }
  24.   QMyObject = class(QObject)
  25.   public
  26.     constructor Create(aParent:QObject);override;
  27.   end;
  28.  
  29. implementation
  30.  
  31. constructor QObject.Create(aParent: QObject);
  32. begin
  33.   { call the static constructor first, but only in this root object }
  34.   inherited create;
  35.   { keeps track of a parent.
  36.     This is the root so the parent is nil}
  37.   Fparent := nil;
  38. end;
  39.  
  40. constructor QMyObject.Create(aParent: QObject);
  41. begin
  42.  { do not forget to call the inherited constructor }
  43.  inherited create(aParent);
  44.  { set the new parent }
  45.  FParent := aParent;
  46. end;
  47.  
  48. end.
You can use this as a direct replacement for the faulty code in your repository.

Side note: I would have expected a correct answer in this discussion, but it was simply not there! That is worrying...
 

« Last Edit: February 12, 2024, 10:39:17 am by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

 

TinyPortal © 2005-2018