Access violation at address 00000000

delphi package - automated exception handling
Post Reply
pcoenen
Posts: 19
Joined: Wed Mar 07, 2018 4:41 pm
Contact:

Access violation at address 00000000

Post by pcoenen »

Hi,

>Access violation at address 00000000. Read of address 00000000.

I'm having an issue with a 64bit Service I've created. I've bought a license because I thought this could be discovered using madExcept. It happened again but no mbr file was created. Setup of mbr is ok because when I force an except the mbr file is created. Any idea in which direction I should search.

Regards,
Pascal
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access violation at address 00000000

Post by madshi »

Are you using any custom code, e.g. have you registered any exception handlers? Or just stock madExcept with maybe some customized settings?

Which Delphi/BCB version?

How do you get the Access violation message, is it an interactive service so you can actually see the Delphi exception window?
pcoenen
Posts: 19
Joined: Wed Mar 07, 2018 4:41 pm
Contact:

Re: Access violation at address 00000000

Post by pcoenen »

ok, sorry not much info from me .. need to learn this

>Are you using any custom code, e.g. have you registered any exception handlers?
I didn't, maybe other third party code I'm using? How do I check this, I have full source code.

>Or just stock madExcept with maybe some customized settings?
Some customized settings because of the service (found this on this forum)

>Which Delphi/BCB version?
Delphi XE7 (all updates)

>How do you get the Access violation message, is it an interactive service so you can actually see the Delphi exception window?
The user send me a screenshot of the MS Windows log (no window).
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access violation at address 00000000

Post by madshi »

Hmmmm... Can you reproduce the AV on your development PC?
pcoenen
Posts: 19
Joined: Wed Mar 07, 2018 4:41 pm
Contact:

Re: Access violation at address 00000000

Post by pcoenen »

No, I don't get on my development system. I've 2 customers with this issue. The service runs 24/7.

I've found the following link: https://stackoverflow.com/questions/223 ... s-00000000
If you get 'Access violation at address 00000000.', you are calling a function pointer that hasn't been assigned - possibly an event handler or a callback function.
If this is the case, would such errors be logged by madExcept?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access violation at address 00000000

Post by madshi »

madExcept by default should catch any *unhandled* exceptions. However, if "somebody" handles exceptions in a try..except block, madExcept will ignore those.

What happens if you raise test exceptions yourself in your service? Does madExcept catch and report those on your development PC? Please test exceptions in different threads, because services are more complicated than normal applications.

AV at address 00000000 does mean that some thread jumped to address "nil". That can be caused by multiple different things. One possibility is a function pointer that hasn't been assigned. There are other possible causes. In any case, madExcept is supposed to catch these things, unless there's a try..except block somewhere catching the exception before madExcept "sees" it.
pcoenen
Posts: 19
Joined: Wed Mar 07, 2018 4:41 pm
Contact:

Re: Access violation at address 00000000

Post by pcoenen »

Added Raise Exception.Create('some test'); at different positions and different threads. Each time an mbr file is created.
In any case, madExcept is supposed to catch these things, unless there's a try..except block somewhere catching the exception before madExcept "sees" it.
I don't think so because the exception is logged by Windows in the Event Log, correct?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Access violation at address 00000000

Post by madshi »

Hmmm... That complicates things. Yes,you're right, if the exception is logged in the Event Log, that suggests that the exception was unhandled.

So why is madExcept not able to catch and report this specific AV? The most likely reason is that in the situation when the crash occurs, your process/service is already in such an unstable situation that madExcept internally crashes while trying to report the original crash. E.g. this could happen if the memory manager got unstable, because madExcept still needs to be able to allocate stuff to do its job.

There are various different situations why your service might go unstable. Often occurring causes are either buffer overruns, or the use of an already feed buffer, or freeing stuff twice, or things like that. Is your service a 32bit or 64bit process? If it's 32bit, you could try activating the "instantly crash on buffer overrun" feature. This feature tries to detect buffer overruns and some other bad things, and when detected, an exception is raised. This exception is raised "early", before the buffer overrun could do damage, so usually reporting this crash will still work ok.

I'd suggest that you first extensively test your service on your dev PC. Maybe you'll already be able to locate a possible buffer overrun? If not, you can let your end user test it. You'll have to distribute the madExcept32.dll with your exe (same folder), otherwise the "instantly crash on buffer overrun" feature will be silently disabled.

Please note that the "instantly crash" feature consumes a ton of extra RAM. So there's some danger that you'll run into "out of RAM" problems. I hope not, that would be a pity. Also please note that "instantly crash" currently only works for 32bit exes.
pcoenen
Posts: 19
Joined: Wed Mar 07, 2018 4:41 pm
Contact:

Re: Access violation at address 00000000

Post by pcoenen »

Update ..

I removed the FastMM4 unit from my Service project (GitHub version) so now my Delphi XE7 is using the original version again. Created a new build of the service and it is running at the user without issues at the moment. To be continued ..
Post Reply