3.3.1 : GetInterfaceByStr crashes with -O1
Using CORBA interfaces does no longer work with 3.3.1. (except -O- )
rev def475f8
The line that fails is: function TObject.GetInterfaceByStr(const iidstr : shortstring;out obj) : boolean; ... if result and Assigned(IEntry^.IID) and (IEntry^.IType in [etStandard, etFieldValue]) then IInterface(obj)._AddRef;
When getting a corba interface you can get to that line with:
Result = true
IEntry^ =
( IIDREF: ^PGUID(nil);
VTABLE: $0000000100719838^: ;
IOFFSET: 32;
IOFFSETASCODEPTR: $0000000000000020^: ;
IIDSTRREF: $00000001007103E8^^: $00000001007103E0^: '';
ITYPE: ETSTANDARD)
IEntry^.IID gets (and appears inlined in the asm below)
function tinterfaceentry.GetIID: pguid;
begin
if Assigned(IIDRef) then
GetIID:=IIDRef^
else
GetIID:=Nil;
The interface for the param is "CORBA". (so IIDRef should be nil, according to comments in the code)
Generated asm (as reported by GDB) / Crash line is marked <<<<<<<<<<<<<
=> Something seems strange. There is a "cmp" without any conditional after it?
..\inc\objpas.inc:922
0000000100012293 807de400 cmpb $0x0,-0x1c(%rbp)
0000000100012297 7441 je 0x1000122da <GETINTERFACEBYSTR+170>
0000000100012299 488b45d8 mov -0x28(%rbp),%rax // EAX = The address pointing to IEntry
..\inc\objpas.inc:924
000000010001229D 31c9 xor %ecx,%ecx
..\inc\objpas.inc:922
000000010001229F 48833800 cmpq $0x0,(%rax)
00000001000122A3 488b00 mov (%rax),%rax // EAX = The first qword in the record. That is RAX = IEntry^.IIDRef
00000001000122A6 488b00 mov (%rax),%rax // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< RAX = 0x0 as expected. But there was no condition to check
00000001000122A9 488b45d8 mov -0x28(%rbp),%rax
00000001000122AD 480f44c1 cmove %rcx,%rax
00000001000122B1 4885c0 test %rax,%rax
00000001000122B4 7424 je 0x1000122da <GETINTERFACEBYSTR+170>
00000001000122B6 488b45d8 mov -0x28(%rbp),%rax
00000001000122BA 8b4020 mov 0x20(%rax),%eax
00000001000122BD 85c0 test %eax,%eax
00000001000122BF 7405 je 0x1000122c6 <GETINTERFACEBYSTR+150>
00000001000122C1 83f803 cmp $0x3,%eax
00000001000122C4 7514 jne 0x1000122da <GETINTERFACEBYSTR+170>
..\inc\objpas.inc:923