This is not a debugger issue.
If you give empty string to dispinterface method, sometimes exception occurs(Out of memory), sometimes doesn't.

Tomohiro Takahashi at 4/9/2012 6:54:04 AM -

I modified [Title], [Description], and [Steps] field as Sysop.
Thanks.

Robert Ogren at 5/4/2012 12:01:44 AM -

I'm seeing this problem as well, in Delphi XE2 Update 4. It especially happens when using TClientDataSet with midaslib and not having midas.dll installed on the client so that TDispatchAppServer is used, resulting in the error message "CommandText changes are not allowed" because the CommandText, which is supposed to be empty, is sent as a long string of garbage to the application server. Report 103983 may therefore be caused by the issue described in this report.

As far as I can see, the problem is in System.Variants, function GetDispatchInvokeArgs, this line:

varOleStr: PVarParm^.VPointer := PWideChar(PWideString(Params)^);

If the string is empty, _WStrToPWChar will return a pointer to a null character, but this is not a valid BSTR as that is supposed to have length information before the string much like Delphi strings. The bytes that happen to be before the EmptyString constant is treated as the string length. The code for other cases in GetDispatchInvokeArgs, such as atString and atUString, has special handling for empty strings.

If necessary, I can provide another simple test case.

Tomohiro Takahashi at 5/17/2012 7:32:28 PM -

This report was opened with valid Internal Tracking Number.
Thanks.

Guy Glirbas at 10/30/2012 4:16:35 PM -

For people hitting this issue, we are tyring this work around fix to Dtasnap.Provider:

procedure TDataSetProvider.SetCommandText(const CommandText: WideString);
begin
if CommandText = '' then Exit;
if CommandText[1] = #0 then Exit; // <----- Work Around
if not (poAllowCommandText in Options) then
DatabaseError(SCannotChangeCommandText);
CheckDataSet;

(DataSet as IProviderSupport).PSSetCommandText(CommandText);
end;

Guy Glirbas at 10/31/2012 12:07:30 PM -

This issue is nastier than I first thought. These empty strings with non zero length cause bad memory issues for our application. Delphi libraries that copy strings aften allocate memory based on the length bytes preceding strings. Our application does not work with XE2. We get out of memory errors and access viloations. Will a hot fix be available or must we upgrade to XE3 to get the fix?