Recent

Author Topic: My DIY dynamic array occurs internal error 2013060101 and I don't know WHY  (Read 2180 times)

TYDQ

  • Full Member
  • ***
  • Posts: 153
These days I have developing my Testing OS and want to use my DIY dynamic array using fpc compilerproc.
However,I met the error about Internal Error 2013060101 and I find the destination about internal error raises using grep -r 2013060101:
These are the code where error occurs in fpc source code:
Code: Pascal  [Select][+][-]
  1. procedure tparamanager.getcgtempparaloc(list: TAsmList; pd: tabstractprocdef; nr : longint; var cgpara: tcgpara);
  2.       begin
  3.         if (nr<1) or (nr>pd.paras.count) then
  4.           InternalError(2013060101);
  5.         pd.init_paraloc_info(callerside);
  6.         cgpara:=tparavarsym(pd.paras[nr-1]).paraloc[callerside].getcopy;
  7.       end;
  8.  
And this is what function that occurs error:
Code: Pascal  [Select][+][-]
  1. procedure fpc_dynarray_assign(var Dest:Pointer;Source:Pointer;TypeInfo:Pointer);compilerproc;
  2. begin
  3.  fpc_dynamic_array_increase_reference(Source); freemem(Dest); Dest:=Source;
  4. end;
And this is the error appears in kernel.pas in my attachments.(If I change testarray1,testarray2 as global variable,the error still occurs as the same.)
Code: Pascal  [Select][+][-]
  1. procedure kernel_main;
  2. var testarray1,testarray2:array of Natuint;
  3. begin //where the error occurs(this line is line 9,kernel.pas(9,1):Internal Error 2013060101)
  4.  testarray1:=[1,3,7,13,21,31];
  5.  testarray2:=copy(testarray1,1,3);
  6.  while True do;
  7. end;
Furthermore,When I put the Dynamic Array Variable to the global variable,the error will disappear like this(If I put the testarray1,testarray2 as temporary variable,the error will occur above):
Code: Pascal  [Select][+][-]
  1. var testarray1,testarray2:array of Natuint;
  2.  
  3. procedure kernel_main;
  4. begin
  5.  SetLength(testarray1,6);
  6.  testarray1[0]:=1; testarray1[1]:=3; testarray1[2]:=7; testarray1[3]:=13; testarray1[4]:=21; testarray1[5]:=31;
  7.  testarray2:=copy(testarray1,1,3);
  8.  while True do;
  9. end;
I know this is my fault,but I don't know why and how to solve.
I know the forum have many free pascal geeks,so I put my problem for every forum members for the answer.
If you want to reshow this error,you can use bash build.sh in linux to show it.
This program is not to be executed due to memory does not have initialization process in this program,I compile it for testing and just want to pass the compile.
« Last Edit: June 12, 2025, 05:54:52 pm by TYDQ »

Joanna

  • Hero Member
  • *****
  • Posts: 1415
If the error occurs when compiling try -> cleanup and build

Thaddy

  • Hero Member
  • *****
  • Posts: 18726
  • To Europe: simply sell USA bonds: dollar collapses
did you compile your kernel with debug info? You should be able what the values of pd.paras.count and nr are
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 360
  • I use FPC [main] 💪🐯💪
FPC [git main] x64 Windows

Code: [Select]
fpc.exe -n -Si -Sc -Sg -Xd -Ur -Us -CX -XXs -Cg BaseUnits/system.pas
fpc.exe -n -Si -Sc -Sg -Xd -Ur -CX -XXs -Cg BaseUnits/objpas.pas
fpc.exe -n -Si -Sc -Sg -Xd -Ur -CX -XXs -Cg BaseUnits/fpintres.pas
fpc.exe -n -Si -Sc -Sg -Xd -Ur -CX -XXs -Cg BaseUnits/sysinit.pas
fpc.exe -n -Si -Sc -Sg -Xd -Ur -CX -XXs -Cg BaseUnits/si_prc.pas
fpc.exe -n -FuBaseUnits Kernel/kernel.pas

Compiled successfully
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 360
  • I use FPC [main] 💪🐯💪
Tried on Linux (Ubuntu 22.04) FPC [git main]

Code: [Select]
Fatal: Internal error 2013060101
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 360
  • I use FPC [main] 💪🐯💪
Tried to reduce to the minimum reproducible state:

I have attached an archive with all the files at the end of the post!

(only works on Linux)

compile:
Code: [Select]
fpc -n -B -Ur -Us system.pas
fpc -n -B -Ur objpas.pas
fpc -n -B -Ur fpintres.pas
fpc -n -B kernel.pas

kernel.pas:
Code: Pascal  [Select][+][-]
  1. program kernel;
  2. type
  3.   TArr = array of byte;
  4. begin
  5.   TArr.Create;
  6. end.

objpas.pas:
Code: Pascal  [Select][+][-]
  1. unit objpas;
  2. interface
  3. implementation
  4. end.

fpintres.pas:
Code: Pascal  [Select][+][-]
  1. unit fpintres;
  2. interface
  3. implementation
  4. end.

system.pas:
Code: Pascal  [Select][+][-]
  1. unit system;
  2. interface
  3. type
  4.   Char=Byte;
  5.   HResult = LongInt;
  6.   TTypeKind = (dummy);
  7.   JMP_Buf = record end;
  8.   TExceptAddr = record end;
  9.   TGuid = record
  10.       D1: LongWord;
  11.       D2: Word;
  12.       D3: Word;
  13.       D4: array [0 .. 7] of Byte;
  14.   end;
  15.  
  16. procedure fpc_setjmp; compilerproc;
  17. procedure fpc_pushexceptaddr; compilerproc;
  18.  
  19. procedure fpc_dynarray_setlength(var ptr: Pointer; PtrTypeInfo: Pointer; DimensionCount: Int64; DimensionLength: Pointer); compilerproc;
  20.  
  21. implementation
  22.  
  23. procedure fpc_setjmp;
  24. begin
  25. end;
  26. procedure fpc_pushexceptaddr;
  27. begin
  28. end;
  29. procedure fpc_dynarray_setlength(var ptr: Pointer; PtrTypeInfo: Pointer; DimensionCount: Int64; DimensionLength: Pointer);
  30. begin
  31. end;
  32.  
  33. end.
I may seem rude - please don't take it personally

ALLIGATOR

  • Sr. Member
  • ****
  • Posts: 360
  • I use FPC [main] 💪🐯💪
Basically, this is a ready-made report for creating an issue on the GitLab tracker

https://gitlab.com/freepascal.org/fpc/source/-/issues/new
I may seem rude - please don't take it personally

Thaddy

  • Hero Member
  • *****
  • Posts: 18726
  • To Europe: simply sell USA bonds: dollar collapses
@ALLIGATOR
Except the bug tracker needs a different ID for logging in. You and I have that.
@TYDQ
Make sure you have an ID for the bug tracker.
« Last Edit: July 11, 2025, 01:59:30 pm by Thaddy »
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

 

TinyPortal © 2005-2018