Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-07

A lot of stuff broke, looking for advice

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Anthony Walter

I have a problem and am looking for advice. The problem is I had been developing on 64-bit Linux using a trunk version of fpc from maybe 2-3 months back and now much of my core library no longer works when I use the latest trunk version of fpc.

Here is what I am doing...

I am working towards publishing the next version of my minimal cross platform game library (http://baregame.org) which includes static linking by default, android support, video textures, programatic audio effects plus 3d sound mixing, post processing effects, much improved vector graphics (everything is done with glsl shaders now), and much more.

I had two tasks for the week.

1) Make builds and test the IDE/framework installer for 32/64bit Windows and Linux including a publish to an Android device
2) Make a series of videos demonstrating what coding with my framework looks like showing what and it does and how the various systems within it fit together on all platforms.

Working on task #1 I have all items working and all my milestones met on 64-bit Linux. I am now trying to recompile and test on 32-bit Linux and then will move on to Windows. While working on testing my changes on 32-bit Linux I encountered some problems I had mentioned in a previous email and bug list (records with interfaces not being initialized/finalized correctly). I decided test an upgraded compiler (which I will need to support eventually) and now a lot of what I've written breaks.

My System and Types unit define a quite a few of generic base classes in the Delphi style including generic constraints. I have types such as:

TEnumerator<T> = class(TInterfacedObject, IEnumerator<T>) TArrayList<T> = record
TCollection<TItem> = class(TInterface, IEnumerable<TItem>) TInterfaceCollection<TItem: IInterface> = class(TCollection<IInterface>) TOwnerCollection<TItem: TObject> = class(TCollection<TItem>) TOwnerNamedCollection<TItem: TObject> = class(TOwnerCollection<TItem>, INamedEnumerable<TItem>)
TList<TItem> = class(TAssignable, IEnumerable<TItem>, ICloneable<TObject>) public

  type ItemType = TItem;
  function GetEnumerator: IEnumerator<ItemType>;

TIndexedList<TItem> = class(TList<TItem>)
TObjectList<TItem: TObject> = class(TIndexedList<TItem>) TNamedObjectList<TItem: TObject> = class(TObjectList<TItem>, INamedEnumerable<TItem>)
TStringList = class(TIndexedList<string>)
IStringEnumerable = IEnumerable<string>
TStringKeys = class(TInterface, IStringEnumerable)

ect...

All units my framework uses these types and those two units heavily, and with an updated fpc trunk compiler they break in a big way. I suspect it may take a quite a bit of effort on my part to get my codebase and working with the current trunk version of fpc based on the number and types of errors I am seeing, some of which are related to generics working differently (I still have a problem with interfaces in not being initialized properly at times). I am not sure how to proceed in fixing these as I feel like this will happen again with another future release of fpc breaking compatibility with the generics I've written. What should I do?

Reply by email

Marco van de Voort
to Anthony Walter

In our previous episode, Anthony Walter said:

Show quoted text 9 lines
All units my framework uses these types and those two units heavily, and with an updated fpc trunk compiler they break in a big way. I suspect it may take a quite a bit of effort on my part to get my codebase and working with the current trunk version of fpc based on the number and types of errors I am seeing, some of which are related to generics working differently (I still have a problem with interfaces in not being initialized properly at times). I am not sure how to proceed in fixing these as I feel like this will happen again with another future release of fpc breaking compatibility with the generics I've written. What should I do?

You are using functionality still in development *in* development version of FPC. That's always risky, and there are no guarantees of timetable there.

Moreover, from your message it is unclear what your direct problem is except on the macro scale of "it doesn't work".

Reply by email

Jonas Maebe
to Anthony Walter: I have a problem and am looking for advice. The problem is I had been developing on…
Anthony Walter wrote 14 lines
All units my framework uses these types and those two units heavily, and with an updated fpc trunk compiler they break in a big way. I suspect it may take a quite a bit of effort on my part to get my codebase and working with the current trunk version of fpc based on the number and types of errors I am seeing, some of which are related to generics working differently (I still have a problem with interfaces in not being initialized properly at times). I am not sure how to proceed in fixing these as I feel like this will happen again with another future release of fpc breaking compatibility with the generics I've written. What should I do?

Nothing about breaking backward compatibility regarding generics is documented at http://wiki.freepascal.org/User_Changes_Trunk, so it may just be a bug (unless you are working in Delphi mode, and the changes improved compatibility with Delphi as far as generics are concerned). As Marco indicated, what you should do very much depends on specifically broke and why it did, and without a concrete example that used to compile but now doesn't anymore it's not really possible to give any useful advice.

Jonas

Reply by email

Anthony Walter
to Jonas Maebe

Here is an example:

{ TObjectList<TItem: TObject> = class(TIndexedList<TItem>) }

bare.types.pas(1176,1) procedure/function constructor Create(Boolean);An unhandled exception occurred at $0816975E:
bare.types.pas(1182,1) procedure/function procedure Clone:TObject; Fatal: Compilation aborted
Error: ppc386 returned an error exitcode

{ TObjectList<TItem> }

constructor TObjectList<TItem>.Create(OwnsObjects: Boolean);
begin // line 1176
  inherited Create;
  FOwnsObjects := OwnsObjects;
end;
function TObjectList<TItem>.Clone: TObject;
begin
  Result := TObjectList<TItem>.Create(False);
  Assign(Result, Self);
end;

Reply by email

Jonas Maebe
to Anthony Walter
Anthony Walter wrote 10 lines
Here is an example: { TObjectList<TItem: TObject> = class(TIndexedList<TItem>) } bare.types.pas(1176,1) procedure/function constructor Create(Boolean);An unhandled exception occurred at $0816975E: bare.types.pas(1182,1) procedure/function procedure Clone:TObject; Fatal: Compilation aborted Error: ppc386 returned an error exitcode

Well, the compiler crashing with an unhandled exception is obviously always a compiler bug, rather than an indication that backward compatibility has been purposefully broken. The interleaved output of the unhandled exception and the errors is also strange.

Show quoted text 13 lines
{ TObjectList<TItem> } constructor TObjectList<TItem>.Create(OwnsObjects: Boolean); begin // line 1176 inherited Create; FOwnsObjects := OwnsObjects; end; function TObjectList<TItem>.Clone: TObject; begin Result := TObjectList<TItem>.Create(False); Assign(Result, Self); end;

Please file a bug report with complete code that can be fed to the compiler to reproduce the crash.

Jonas

Reply by email

Sven Barth
to Jonas Maebe
Jonas Maebe wrote 34 lines
On 08 Jul 2013, at 16:39, Anthony Walter wrote: > Here is an example: > > { TObjectList<TItem: TObject> = class(TIndexedList<TItem>) } > > bare.types.pas(1176,1) procedure/function constructor Create(Boolean);An > unhandled exception occurred at $0816975E: > bare.types.pas(1182,1) procedure/function procedure Clone:TObject; > Fatal: Compilation aborted > Error: ppc386 returned an error exitcode Well, the compiler crashing with an unhandled exception is obviously always a compiler bug, rather than an indication that backward compatibility has been purposefully broken. The interleaved output of the unhandled exception and the errors is also strange. > { TObjectList<TItem> } > > constructor TObjectList<TItem>.Create(OwnsObjects: Boolean); > begin // line 1176 > inherited Create; > FOwnsObjects := OwnsObjects; > end; > > function TObjectList<TItem>.Clone: TObject; > begin > Result := TObjectList<TItem>.Create(False); > Assign(Result, Self); > end; Please file a bug report with complete code that can be fed to the compiler to reproduce the crash.

I agree with Jonas here. While you are indeed using a feature that's in the development version of FPC (and it's not called "development version" for fun), I've not broken anything generics related on purpose, otherwise I'd have documented it in the approbiate places.

Also if you see "unhandled exception" or "internal error" in the compiler's output this normally always points to a bug. So please report it, so it can be fixed.

Regards,
Sven

Reply by email