Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi App Communicates with Program That Ends Up Crashing Occasionally - Vendor Blames My Delphi App

I've written a Delphi DLL that communicates with a third party program via COM. Some users report that the third party program crashes occasionally. Others using the software in an identical fashion have never experienced a crash. When this crash occurs, the third party program appears to simply become unavailable in my DLL app.

The vendor swears that it is a problem with how the Delphi DLL is coded, although they have not seen the source code and can't tell what what the DLL is doing to cause the crash, but they know it's "something".

Aside from the fact that I believe that the third party program shouldn't be crashing due to some minuscule problem in my DLL, let's assume that there is something in my DLL that needs fixing.

How can I determine how my app might be causing this? Does anyone have experience communicating via COM with a hyper-sensitive program like this? Are there some common things to look for that might be crashing the third party program?

like image 759
Dave Avatar asked Dec 04 '22 15:12

Dave


1 Answers

  1. Make the customer happy.
  2. Don't assume it's not your dll, it could be. Even if "Others using the software in an identical fashion have never experienced a crash", it could be that with different data, it does different things...
  3. I'd suggest that you setup logging to a textfile in a "special" diagnostic version.
  4. Log everything, your parameters, your exceptions, and the steps you're going through. Maybe even the start and end of every function, and every other line.

Here's how it could look...

Loaded DLL
Started MyFunction1 with parameters: 1,4,hello
   1
   2
   ...
   500
Ended MyFunction1

to make that,,, I'd setup a few functions (in their own unit):

// opens a text file (fixed name), and appends to it.
function InitializeLog; 

// closes the file
function CloseLog;      

//add a log line.
function Log(message:string='', startNewFunction:boolean:False); 

you would call it like this:

function MyFunction1(Integer,Integer,String);
begin
  try
    Log('Loaded DLL');

    //use inttostr and do some string concats to get the params
    Log('Started MyFunction1 with parameters: 1,4,hello',true); 

    //Then every other line:
    Log; 
    //this would increment a global variable FuncLine:Integer
    //and write it to the file.    

  except
    On E:Exception (Log('***'+E.Message));
  end;
end;

Something like this should have a {$DEFINE} to enable these logging functions, to enable/disable the diagnostic logging.

This could also be useful.

like image 136
Osama Al-Maadeed Avatar answered Dec 22 '22 00:12

Osama Al-Maadeed