Exception when performing design-time call

Hello,

We have a Delphi design-time module in which we execute Data Abstract calls.
For some developers, it does not work. For others, it worked initially, but stopped working.

After some debugging, the code which fails can be reduced to:

procedure TDADatasetComponentEditor.TestROCache;

Var
a : TClass;

begin
try
a:=uRORTTISupport.RORTTI_GetExceptionClass(‘SessionNotFoundException’,Nil);
ShowMessage(‘OK’);
except
On E : exception do
ShowMessage(Format(‘Failed: %s %s’,[E.ClassName,E.Message]));
end;
end;

(this is a component editor method, simply invoked by right-clicking a component and selecting a method we made)

This is the result:

If we remove the try…except block, we can see that madexcept reports the following stack trace:

(the same stacktrace can be observed with other tools)

Any ideas what could cause this, or has this been observed before ?

Hi,

odd, but I can’t reproduce this with simple method of design-time editor.
can you specify bds.exe as a host for your package and launch it in debugger and see what causes this issue, pls?

It happens in TRORttiClientCache.RebuildCache.

Attached screenshot:

The call to isROComplexType fails, it seems to get an invalid pointer.
I tried to find out what class this is, but the name does not seem to be available.

Does your package register RO/DA exception?
can you simplify and share your package so it can reproduce this issue?

by other hand, you can try to disable optimization and inlining for RO_CORE package so we can see what class is failed

After I changed the uRORTTISupport unit to store package/class name in a local variable which I can check in the debugger, I found the cause.

The following definition seems to confuse the compiler/rtti:

TMyObject = Type TObject;

Changing it to
TMyObject = Class(TObject);

allows the code to run without problems.

I got curious and found out that the following code:

Type
TMyObject = Type TObject;

Var
S : TMyObject;

begin
S:=TMyObject.Create;
end.

Fails to compile with the following error:

[dcc32 Error] testobjecttype.dpr(17): E2010 Incompatible types: ‘TMyObject’ and ‘TObject’

Which is very strange…

IMHO, type x can be applicable for simple types only and not for objects