View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0026874 | FPC | Documentation | public | 2014-10-16 20:47 | 2015-08-13 16:36 |
Reporter | Adriaan van Os | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | Windows | OS | Win32 | ||
Product Version | 2.6.0 | ||||
Target Version | 3.0.0 | Fixed in Version | 3.0.0 | ||
Summary | 0026874: Discuss low level handling of reference counted interfaces | ||||
Description | This bug report is a follow-up of on the thread "Reference counting interface objects" on the fpc-devel mailing list of October 16, 2014. It suggests to discuss low-level handling of reference counted interfaces in the FPC documentation. As mentioned on the thread, in Pascal code _Release doesn't need to be called, since the purpose of reference counting is to handle this automatically. However, when interfacing with external code, the internal rules must be precisely known. For example, when writing bindings for external interfaces, the difference between VAR en OUT becomes essential. An OUT parameter in external COM code that is declared VAR in the Pascal bindings, produces a memory leak on each call. To understand this, the low-level details must be known. | ||||
Additional Information | Jonas Maebe wrote: Regarding the effects of the various qualifiers: * nothing (value): the reference count of the parameter is increased (I forgot whether it's the caller or callee that does it) on entry and decreased on exit * OUT: the reference count of the value that's passed in is decreased by 1, and the variable that's passed into the procedure is initialized to "empty" (nil, but that's an implementation detail) * VAR: nothing happens to the reference count. A reference to the original variable is passed in, and changing it or reading it has exactly the same effect as changing/reading the original variable. * CONST: this is the only tricky one. Again nothing happens to the reference count, but because you can pass non-lvalues here. In particular, you can pass a class implementing an interface rather than the interface itself, which can cause the class to be freed unexpectedly. See the example at http://docwiki.embarcadero.com/RADStudio/XE7/en/Using_Reference_Counting . The same can happen with functions returning a class instance passed to a function expecting a CONST interface parameter. There is an open bug report about adding a warning for it: http://bugs.freepascal.org/view.php?id=19503 | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 1151 | ||||
FPCOldBugId | 0 | ||||
FPCTarget | |||||
Attached Files |
|
has duplicate | 0028504 | resolved | Jonas Maebe | class(TInterfacedObject, ITestListener) crashes with SIGSEGV |
related to | 0026593 | resolved | Michael Van Canneyt | (Corba) Interfaces returned from functions are pushed as implicit parameter. |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-10-16 20:47 | Adriaan van Os | New Issue | |
2014-10-16 20:47 | Adriaan van Os | Status | new => assigned |
2014-10-16 20:47 | Adriaan van Os | Assigned To | => Michael Van Canneyt |
2015-03-23 19:25 | Michael Van Canneyt | Fixed in Revision | => 1151 |
2015-03-23 19:25 | Michael Van Canneyt | Note Added: 0082230 | |
2015-03-23 19:25 | Michael Van Canneyt | Status | assigned => resolved |
2015-03-23 19:25 | Michael Van Canneyt | Fixed in Version | => 4.0.0 |
2015-03-23 19:25 | Michael Van Canneyt | Resolution | open => fixed |
2015-03-23 19:25 | Michael Van Canneyt | Target Version | => 3.0.0 |
2015-03-23 19:32 | Michael Van Canneyt | Relationship added | related to 0026593 |
2015-06-13 16:00 | Adriaan van Os | Status | resolved => closed |
2015-08-12 22:31 | Joost van der Sluis | Fixed in Version | 4.0.0 => 3.0.1 |
2015-08-13 16:36 | Jonas Maebe | Relationship added | related to 0028504 |
2015-08-14 08:54 | Jonas Maebe | Relationship replaced | has duplicate 0028504 |