3

When I make a call to a SOAP API method I am getting the following message:

First chance exception at $74EDB9BC. Exception class EAccessViolation with 
message 'Access violation at address 007004F6 in module 'DB2.exe'. 
Read of address 00000005'. Process DB2.exe (3768)

Here is what I am getting from the stack trace:

74EDB9AF 8945C0        mov [epb-$40],eax
74EDB9B2 8D45B0        lea eax,[edp-$50]
74EDB9B5 50            push eax
74EDB9B6 FF155C11ED74  call dword ptr [$74ed115c]
74EDB9BC C9            leave

I am not very familiar with Delphi (just maintaining an older program). Can someone tell me how to debug what is happening here? I am using Delphi 2005.

Here is the code that is failing. The error comes when calling UpdateContact and I know the data for aContact & FCompanyID are there and correct:

function TScheduleCenterBeta.AccountUpdate(aContact: c_ScheduleCenterBetaAPI.Contact): boolean;
begin
  try
    SendAuthHeader();
    FContact := FSoapService.UpdateContact(aContact, FCompanyID);
  except
    on e:Exception do begin
      MessageDlg(e.Message,mtWarning,[mbOK],0);
    end;
  end;
  result := true;
end;

The object FContact is created when creating the master object:

constructor TScheduleCenterBeta.Create(aOwner: TComponent; aCallID: integer = -1);
begin
  inherited Create(aOwner);

  FCallID := aCallID;
  FCompanyID := c_ScheduleCenterBetaAPI.CompanyID.Create();
  FCompanyID.ServiceCompanyID := StrToInt(TfrmCall(Screen.ActiveForm).Company.IP_CompanyID);
  FProperty_ := c_ScheduleCenterBetaAPI.Property_.Create();
  FContact := c_ScheduleCenterBetaAPI.Contact.Create();
  FContact.ContactID := -1;
  FContact.Address := c_ScheduleCenterBetaAPI.Address.Create();
  FAppointmentSlot := c_ScheduleCenterBetaAPI.AppointmentSlot.Create();
end;

One other oddity is that the error comes and goes. If I stop the program and then start it again (using Delphi debug mode) I may or may not encounter the error. I have also restarted Delphi to make sure it wasn't something with Delphi itself but that didn't seem to change anything.

Prix
  • 19,417
  • 15
  • 73
  • 132
BrianKE
  • 4,035
  • 13
  • 65
  • 115
  • 3
    Please provide your Delphi code around API method call. – valex Aug 15 '12 at 12:40
  • You could start by providing the actual code. The address in the Exception message (00000005) indicates you're probably using a nil pointer or uninitialized variable, but it's hard to tell you more than that without more info. If you have the **exact** dcus that were linked to build that exe, you might be able to use the first address to try and locate it. – Ken White Aug 15 '12 at 12:42
  • Normally this is because you delcared say a pointer to a string, but didnt set it up before trying to fill it. – BugFinder Aug 15 '12 at 12:45
  • i suggest you to add debug info and exception stack trace. So you would better see where exactly exception happened. There are a lot of tools, free and commercial, some are mentioned at http://stackoverflow.com/questions/11937853 and http://stackoverflow.com/questions/258727 . If program trashes its memory badly, they can make failure even worse. But usually they work okay and give you more details of crash. http://www.rsdn.ru/article/Delphi/DelphiJCL%5CCallStack_Strip.PNG – Arioch 'The Aug 15 '12 at 14:02
  • is DB2.exe the name of your application or a third part dll? – Toby Allen Aug 15 '12 at 14:31
  • DB2.exe is the name of our application. – BrianKE Aug 15 '12 at 14:37
  • Regarding the version, when I go to Help -> About Borland Developer Studio the window says "Borland Developer Studio for Microsoft Windows Version 9.0.176.24408". I don't see anything else that would indicate a different version of Delphi. – BrianKE Aug 15 '12 at 14:40
  • 1
    Debug your app and work out which pointer is nil. – David Heffernan Aug 15 '12 at 16:52
  • ROB: this is 2005, didn't think to look in those other areas. Also, what happened to the comment you posted? I tried to reply to it and it was gone. If it helps UpdateContact does return a Contact object. – BrianKE Aug 15 '12 at 17:40
  • The two comments I posted are still here (but now that you've answered my question, I can delete them and edit your question to incorporate the new information). I think you're referring to the *answer* (not comment) from Ken. He deleted it about two and a half hours after he posted it. Please use `@` when replying to comments so that the person you reply to is notified. (I didn't have to do that here because it's your question, so you're automatically notified of everything.) – Rob Kennedy Aug 15 '12 at 20:46

0 Answers0