views:

101

answers:

2

We have some code something like this (Delphi 6 RTL Update Pack 3):

objChild1 := TChild1.create();
... (Some Code)
objProcessor.function1(objChild1);

Tchild1 is inherited from TGrandPa through 2 + hierarchy levels.

function1 is defined like this where objChildData is a private variable of TProcessor class and is of type TChild1 :

TProcessor.function1(objTemp : TGrandPa):boolean;    
begin
    objChildData := TChild1(objTemp);
    ....
end;

From the logs (since we can't debug on a customer machine), we have narrowed down that the first line in the function1 makes objChildData nil sometimes and only on one particular customer's machines. Rest of the places where same code is deployed seems to be working perfectly fine.

Can anyone throw some light on why this is happening and/or how to resolve this?

+1  A: 

Seems you are doing something on the ObjChild.Create that throws an exception and that is swallowed (try..except where the except clause is empty) for some reason - when that happens, Create cannot return a valid instance, returning NIL instead. It can be an function called inside the constructor.

If you bring what you do on the TObjChild.Create to the site, maybe we can spot the problem.

Fabricio Araujo
A: 

You are able to debug the code running on a customer machine using Remote Debugger (available since Delphi 3 or 4).

Anyway, by the logs how are you sure objTemp parameter is not nil?

jachguate