Access Violation (Delphi) - except the first run

2

I have a POS application written in Delphi, which has been working fine until now.

I had to add a webservice client to have some documents validated by the goverment, and even though I had never worked with WebServices/Encryption before, I managed to do it (thanks to the internet really).

When I run the program and create one of those documents, it is perfectly validated (the webservice is accessed, a SOAP envelope with some data is sent, and the response from the server is received without any problems).

The problem is, if I create another document, when I try to validate it I get an "Access Violation at 0x07e7bcb5: read of address 0x00000012".

My validation routine is a function inside a DLL. Before it was inside the DLL, I had all the code inside the main project, but it crashed my program: if I would validate a document, the response would come, but I would get an Access Violation when I terminated the program or if I tried to validate another. I also tried loading the DLL dinamically, so the validation process would "start from scratch" at each run, but it was useless.

I've been trying to debug this, but I just can't get it. Running step by step, it fails in some line, I comment it out, and the next run it fails in a completely different place. I tried also EurekaLog, but I couldn't figure out what to do with the info it gave me (I had never worked with it).

Any direction I should be taking?

Thank you very much! Nuno Picado

EDIT: I should probably mention what I'm using to access the webservice: - THTTPReqResp and WinINet for the communication - IXMLDocument to create the SOAP Envelope - LibEay32 to encript some data required by the webservice - TZDB to get the universal time from a web based server - Capicom 2.0 to load a certificate required for the communication

web-services
delphi
soap
dll
access-violation
asked on Stack Overflow Jun 10, 2013 by nunopicado • edited Jun 10, 2013 by nunopicado

1 Answer

4

I use EurekaLog at work, to debug errors that happen at client installations. Here's what you do with the information EurekaLog gives you:

Fairly high up in the report should be one stack trace for every thread in the program. The one on top should be the one in which the error occurred. That's almost always the most important thing in the error log: it tells you exactly what was going on when the exception was raised.

Find the place in your code that corresponds to the top of the stack trace. An access violation means that somewhere, your code tried to access (read, in this case) memory that's not mapped to your program's address space. A bunch of leading 0s means that you're trying to read at an offset from a null pointer. This almost always means one of three things: You're trying to read the value of an object whose value is nil, you're trying to call a virtual method on an object whose value is nil, or you're trying to read an element of a string or dynamic array whose length is 0 (and this is currently represented by a null pointer).

Now that you know what you're looking for, have a look at the code and see if there's any way that that could be happening based on the information you have available.

answered on Stack Overflow Jun 10, 2013 by Mason Wheeler

User contributions licensed under CC BY-SA 3.0