[fpc-devel] Unwanted finalization
Yury Sidorov
jura at cp-lab.com
Sat Oct 13 18:01:20 CEST 2012
Hi,
Funny, but I have also encountered the problem in this place yesterday
:) But with PVariant(VarResult)^ in my case.
Yes, the declaration of ITypeInfo.Invoke() should be changed to
eliminate unwanted compiler magic with managed types when a nil is
passed.
I'll commit the required changes today or tomorrow.
Best Regards!
Yury Sidorov.
----- Original Message -----
From: "Ludo Brands" <ludo.brands at free.fr>
To: "'FPC developers' list'" <fpc-devel at lists.freepascal.org>
Sent: Saturday, October 13, 2012 6:34 PM
Subject: [fpc-devel] Unwanted finalization
Dear all,
In comobj.pp I'm getting sometimes a SIGSEGV in the following code:
function TAutoObject.Invoke(DispID: LongInt; const iid: TGUID;
LocaleID: longint; Flags: Word; var params; VarResult,
ExcepInfo,
ArgErr: pointer): HResult; stdcall;
...
begin
...
Result :=
TAutoObjectFactory(Factory).DispTypeInfo.Invoke(Pointer(
PtrUint(Self) +
TAutoObjectFactory(Factory).DispIntfEntry^.IOffset),
DispID, Flags, TDispParams(Params), PVariant(VarResult)^,
PExcepInfo(ExcepInfo)^, PUINT(ArgErr)^);
...
end;
The interface method called (ITypeInfo::Invoke) is defined in
activex.pp as
Function Invoke(pvInstance: Pointer; memid: MEMBERID; wFlags:
WORD;
VAR pDispParams: DISPPARAMS; OUT pVarResult: VARIANT; OUT pExcepInfo:
EXCEPINFO; OUT puArgErr: UINT):HResult;StdCall;
The problem is with the ExcepInfo parameter which is a record.
ITypeInfo::Invoke can have a null pExcepInfo parameter and the
PExcepInfo(ExcepInfo)^ cast causes a call to fpc_finalize with a null
pointer.
Is there a way to avoid the finalisation of PExcepInfo(ExcepInfo)^ ?
EXCEPINFO has a widestring member...
IMO the ITypeInfo::Invoke method should be changed to
Function Invoke(pvInstance: Pointer; memid: MEMBERID; wFlags:
WORD;
VAR pDispParams: DISPPARAMS; pVarResult: PVARIANT; pExcepInfo:
PEXCEPINFO;
puArgErr: PUINT):HResult;StdCall;
but that requires changing all the code that calls this method. On the
other
hand I'm afraid that any code calling this method with the current
definition will have potentially the same problem with the
finalization of
the EXCEPINFO record.
Ludo
_______________________________________________
fpc-devel maillist - fpc-devel at lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
More information about the fpc-devel
mailing list