View Issue Details

IDProjectCategoryView StatusLast Update
0015209FPCCompilerpublic2009-12-24 20:35
ReporterDenis Golovan Assigned ToFlorian  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformLinux 
Product Version2.5.1 
Fixed in Version2.6.0 
Summary0015209: Interface using Implements gives crash
DescriptionImplements keyword gives invalid internal realization if read clause contains function.

See attached test case.
Tested using FPC SVN rev.14281
Tagsimplements, interface
Fixed in Revision14466
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0004842 assignedIvo Steinmann implements keyword in properties 

Activities

2009-11-28 18:15

 

project1.lpr (1,203 bytes)

Sergei Gorelkin

2009-12-03 03:25

developer   ~0032680

See the attached patch.

2009-12-03 06:05

 

15209a.patch (723 bytes)   
Index: ncnv.pas
===================================================================
--- ncnv.pas	(revision 14295)
+++ ncnv.pas	(working copy)
@@ -2699,6 +2699,9 @@
                        begin
                          result:=left;
                          propaccesslist_to_node(result,tpropertysym(implintf.implementsgetter).owner,tpropertysym(implintf.implementsgetter).propaccesslist[palt_read]);
+                         { this ensures proper refcounting when field is of class type }
+                         if not is_interface(result.resultdef) then
+                           inserttypeconv(result, resultdef);
                          left:=nil;
                        end
                      else
15209a.patch (723 bytes)   

Sergei Gorelkin

2009-12-03 06:08

developer   ~0032683

While I'm at the point, here's another patch (15209a.patch) that partially fixes timplements4, timplements4a, timplements4b and timplements7 tests. These four tests no longer crash, and two of them (4 and 7) even started to work correctly.

Denis Golovan

2009-12-08 18:53

reporter   ~0032813

Hi Sergei

I merged both of your patches, but test project (attached) now crashes even on casting C1 as IIntf2. If I remember correctly before patches, it was Print2 that caused troubles.
FPC is rev 14286.

P.S. Sorry for later answer, I really appreciate your help.

2009-12-09 19:16

 

15209_2.zip (1,751 bytes)

2009-12-09 19:16

 

tcorbaimpl.pas (1,483 bytes)

Sergei Gorelkin

2009-12-09 19:24

developer   ~0032856

Yep, messed things up a bit, as it always happens :-/

I replaced the patch with a corrected one (15209_2.zip). Hope now it will work.

Note that there's error in your example: TClass1.GetIntf2 references the property rather than the field, so calling it will cause infinite recursion.

Also uploaded 'tcorbaimpl.pas' - a test, closely based on your example, but using CORBA interfaces instead. It explains why changes to getinterfacebyentry are required. Should be added to the testsuite.

Denis Golovan

2009-12-10 21:03

reporter   ~0032921

This time symbol IsDelegatedByClassField is not defined anywhere.
I updated to svn head, checked again and seems like it remained in your private build.

make[1]: Entering directory `/usr/local/lib/fpc/source/compiler'
/usr/bin/mkdir -p i386/units/i386-linux
/usr/local/bin/ppc386 -Ur -Xs -O2 -n -Fui386 -Fusystems -Fu/usr/local/lib/fpc/source/rtl/units/i386-linux -Fii386 -FE. -FUi386/units/i386-linux -dRELEASE -di386 -dGDB -dBROWSERLOG -Fux86 pp.pas
nobj.pas(656,26) Error: identifier idents no member "IsDelegatedByClassField"
nobj.pas(1304,35) Error: identifier idents no member "IsDelegatedByClassField"

Sergei Gorelkin

2009-12-11 10:02

developer   ~0032935

Exactly :(

I am currently trying to patch other delegation-related issues, so my local sources are a bit unclean. Sorry.
Can you simply revert that non-compiling part? It isn't relevant to the subject matter anyway.

If not, I'll post an updated patch a bit later.

2009-12-11 14:00

 

15209_full.zip (2,625 bytes)

Sergei Gorelkin

2009-12-11 14:02

developer   ~0032961

Attached an updated patch (15209_full.zip). It also fixes outstanding issues with delegating interfaces to class properties.

Denis Golovan

2009-12-11 19:16

reporter   ~0032973

Hooray!
Now it works. I tested both your and my examples.
Others projects also seem work fine.
Thanks a lot.

I owe you a beer :)

I think it should be merged to mainline.

2009-12-18 16:54

 

15209a.zip (2,649 bytes)

2009-12-18 16:55

 

tdel.pp (2,365 bytes)

Sergei Gorelkin

2009-12-18 16:59

developer   ~0033173

Attached a slightly modified patch (15209a.zip). The difference is:

- the TInterfaceEntry type is reordered so the newly added members are at the end.
- GetInterface does not AddRef() on COM interfaces if getter is a function, prevents unbalanced refcounting resulting in memory leaks. A test to demonstrate/check this is added too (tdel.pp).

Denis Golovan

2009-12-22 21:26

reporter   ~0033269

Yeap. Seems like it works.
Thanks.

Denis Golovan

2009-12-24 20:35

reporter   ~0033304

Tested. Works fine.

Issue History

Date Modified Username Field Change
2009-11-28 18:15 Denis Golovan New Issue
2009-11-28 18:15 Denis Golovan File Added: project1.lpr
2009-11-28 18:25 Denis Golovan Tag Attached: implements
2009-11-28 18:25 Denis Golovan Tag Attached: interface
2009-12-03 03:24 Sergei Gorelkin File Added: 15209.zip
2009-12-03 03:25 Sergei Gorelkin Note Added: 0032680
2009-12-03 06:05 Sergei Gorelkin File Added: 15209a.patch
2009-12-03 06:08 Sergei Gorelkin Note Added: 0032683
2009-12-08 18:53 Denis Golovan Note Added: 0032813
2009-12-09 19:16 Sergei Gorelkin File Added: 15209_2.zip
2009-12-09 19:16 Sergei Gorelkin File Deleted: 15209.zip
2009-12-09 19:16 Sergei Gorelkin File Added: tcorbaimpl.pas
2009-12-09 19:24 Sergei Gorelkin Note Added: 0032856
2009-12-10 21:03 Denis Golovan Note Added: 0032921
2009-12-11 10:02 Sergei Gorelkin Note Added: 0032935
2009-12-11 14:00 Sergei Gorelkin File Added: 15209_full.zip
2009-12-11 14:02 Sergei Gorelkin Note Added: 0032961
2009-12-11 16:05 Jonas Maebe Relationship added related to 0004842
2009-12-11 19:16 Denis Golovan Note Added: 0032973
2009-12-18 16:54 Sergei Gorelkin File Added: 15209a.zip
2009-12-18 16:55 Sergei Gorelkin File Added: tdel.pp
2009-12-18 16:59 Sergei Gorelkin Note Added: 0033173
2009-12-22 21:26 Denis Golovan Note Added: 0033269
2009-12-23 17:23 Florian Fixed in Revision => 14466
2009-12-23 17:23 Florian Status new => resolved
2009-12-23 17:23 Florian Fixed in Version => 2.5.1
2009-12-23 17:23 Florian Resolution open => fixed
2009-12-23 17:23 Florian Assigned To => Florian
2009-12-24 20:35 Denis Golovan Status resolved => closed
2009-12-24 20:35 Denis Golovan Note Added: 0033304