Results 1 to 7 of 7

Thread: internal error

  1. #1
    Reader
    Join Date
    May 2002
    Location
    Holland
    Posts
    3,382

    internal error

    Wat kan de oorzaak zijn van onderstaande compiler error in freepascal?
    Het is een delphi-unit (met o.a. nogal wat low level helpers) die niet "wil".

    Code:
    function FindUnitSymtable(st:TSymtable):TSymtable;
          begin
            result:=nil;
            repeat
              if not assigned(st) then
               internalerror(200602034);
              case st.symtabletype of

  2. #2
    mov rax,marcov; push rax marcov's Avatar
    Join Date
    Apr 2004
    Location
    Ehv, Nl
    Posts
    10,357
    IEs zijn altijd bugs in the compiler, en dienen dus gemeld te worden in mantis

    Maar vaak zijn het een soort asserts. Je lost het ene pad naar de IE op, maar er kunnen er meerdere zijn.

    Hier lijkt het alsof er een unit gereferenced wordt die nog niet volledig geladen is. Typisch gebeuren dit soort bugs in gevallen van zware mutuele inclusie vaak in combinatie met inline directives.

    Je kan dus proberen de uses clauses te trimmen en afhankelijkheids (-cycli) te verminderen, en inline onder een ifdef te zetten en ook eens zonder te proberen.

    Maar lange termijn: minimalizeren en dan rapporteren.

  3. #3
    Reader
    Join Date
    May 2002
    Location
    Holland
    Posts
    3,382
    Ok. Thanks!

  4. #4
    Reader
    Join Date
    May 2002
    Location
    Holland
    Posts
    3,382
    Het lijkt erop dat de internal error door de 'kruisverwijzing' in de TEnumeratorForFastList komt.

    Code:
    unit Base.Utils;
    
    interface
    
    uses
      System.Types, System.Classes, System.SysUtils, System.TypInfo, System.IniFiles, System.Math, System.Contnrs,
      
      TFastObjectList<T: class> = class;
    
      // fastest possible 'for in' loop support
      TEnumeratorForFastList<T: class> = record
      private
        fIndex: Integer;
        fList: TFastObjectList<T>;
      public
        function MoveNext: Boolean; inline;
        function GetCurrent: T; inline;
        property Current: T read GetCurrent;
      end;
    
      // fast typed object list
      TFastObjectList<T: class> = class(TObjectList)
      public
        function GetEnumerator: TEnumeratorForFastList<T>; inline;
        function ValidIndex(ix: Integer): Boolean; inline;
        procedure CheckIndex(aIndex: Integer);
        function GetItem(aIndex: Integer): T; inline;
        function First: T; inline;
        function Last: T; inline;
        function FirstOrDefault: T; inline;
        function LastOrDefault: T; inline;
        function HasItems: Boolean; inline;
        function IsEmpty: Boolean; inline;
        function ToArray: TArray<T>;
        property Items[aIndex: Integer]: T read GetItem; default;
      end;
    
    implementation
    
    { TEnumeratorForFastList<T> }
    
    function TEnumeratorForFastList<T>.GetCurrent: T;
    begin
      Result := fList.List[fIndex];
    end;
    
    function TEnumeratorForFastList<T>.MoveNext: Boolean;
    begin
      Inc(fIndex);
      Result := fIndex < fList.Count;
    end;
    
    { TFastObjectList<T> }
    
    function TFastObjectList<T>.ValidIndex(ix: Integer): Boolean;
    begin
      Result := (ix >= 0) and (ix < Count);
    end;
    
    function TFastObjectList<T>.GetItem(aIndex: Integer): T;
    begin
      Result := List[aIndex];
    end;
    
    function TFastObjectList<T>.First: T;
    begin
      Result := GetItem(0);
    end;
    
    function TFastObjectList<T>.Last: T;
    begin
      Result := GetItem(Count - 1);
    end;
    
    function TFastObjectList<T>.FirstOrDefault: T;
    begin
      if Count > 0
      then Result := GetItem(0)
      else Result := nil;
    end;
    
    function TFastObjectList<T>.LastOrDefault: T;
    begin
      if Count > 0
      then Result := GetItem(Count - 1)
      else Result := nil;
    end;
    
    function TFastObjectList<T>.HasItems: Boolean;
    begin
      Result := Count > 0;
    end;
    
    function TFastObjectList<T>.IsEmpty: Boolean;
    begin
      Result := Count = 0;
    end;
    
    function TFastObjectList<T>.GetEnumerator: TEnumeratorForFastList<T>;
    begin
      // we do not use a record constructor. this is faster
      Result.fIndex := -1;
      Result.fList := Self;
    end;
    
    function TFastObjectList<T>.ToArray: TArray<T>;
    begin
      SetLength(Result, Count);
      if Count > 0 then
        System.Move(List[0], Result[0], Count * SizeOf(T));
    end;
    
    end.

  5. #5
    mov rax,marcov; push rax marcov's Avatar
    Join Date
    Apr 2004
    Location
    Ehv, Nl
    Posts
    10,357
    Tis al bekend lijkt het: https://bugs.freepascal.org/view.php?id=22402

    Workaround: nest het iterator record binnen de objectlist.

  6. #6
    Reader
    Join Date
    May 2002
    Location
    Holland
    Posts
    3,382
    Aha. Ik laat het weten!

  7. #7
    Reader
    Join Date
    May 2002
    Location
    Holland
    Posts
    3,382
    Werkt correct!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •