#1  
Old 16th May 2019, 08:16 AM
David Miller
 
Posts: n/a
Default Need help how to find access violation in code

I have reports from some clients about the following error message when
they exit my application. It does not happen to all my clients, but
for those that it does happen, it happens every night when they exit my
application.

=====
Original Application Events Exception: Access violation at address
00000000 in module 'Cap.exe'. Read of address 00000000
=====

Because of the 00000000, I suspect this error has to do with accessing
a null pointer. The problem is that I cannot duplicate the error on my
development machine where I can run a debugger. I have tried many
times to get my application to give me this error, but it never does.
So I can't figure out where in the application the fault lies for
creating the error.

The weird thing is that if I remotely connect to a clients computer and
try to duplicate the error, it does not appear. Only if the
application has been in use all day, and the client attempts to exit
the application, then the error message appears for them.

Can anyone point me in the right direction for how I can locate where
in the code this error is happening?
--


--

  #2  
Old 16th May 2019, 08:19 AM
David Miller
 
Posts: n/a
Default Re: Need help how to find access violation in code

In another version of my application, the error reads as follows:

===
Exception EAccessViolation in module rtl210.bpl at 00000000.
Access violation at address 00000000 in module 'Cap.exe'.
Read of address 00000000.
===


--

  #3  
Old 16th May 2019, 08:46 AM
Thorsten Engler [NDA]
 
Posts: n/a
Default Re: Need help how to find access violation in code

The red flag here is that it's an access violation AT 00000000

That means this is probably a call against a procedure or method pointer that's
nil.

The "read" access violation then occurs after the jump when the CPU tries to
read the next instruction to execute.


David Miller wrote:

> I have reports from some clients about the following error message when
> they exit my application. It does not happen to all my clients, but
> for those that it does happen, it happens every night when they exit my
> application.
>
> =====
> Original Application Events Exception: Access violation at address
> 00000000 in module 'Cap.exe'. Read of address 00000000
> =====
>
> Because of the 00000000, I suspect this error has to do with accessing
> a null pointer. The problem is that I cannot duplicate the error on my
> development machine where I can run a debugger. I have tried many
> times to get my application to give me this error, but it never does.
> So I can't figure out where in the application the fault lies for
> creating the error.
>
> The weird thing is that if I remotely connect to a clients computer and
> try to duplicate the error, it does not appear. Only if the
> application has been in use all day, and the client attempts to exit
> the application, then the error message appears for them.
>
> Can anyone point me in the right direction for how I can locate where
> in the code this error is happening?


  #4  
Old 16th May 2019, 10:04 AM
Eivind Bakkestuen [NDD]
 
Posts: n/a
Default Re: Need help how to find access violation in code

> Can anyone point me in the right direction for how I can locate where
> in the code this error is happening?


Exception stack trace logging may help you locate the area to study.
You can include our nxExceptionHook unit into your application (you'll
also need the open source JCL installed and on your search path); copy
our nxExeConst unit into your project direcory, and edit the constant
inside to match your company and application name; turn on debug info
and full map file; in the Project | JCL menu item, turn on inserting
JCL debug info; and then your application should log exceptions just
like our binaries do (logs saved under c:\programdata\yourcompany...).

--
Eivind Bakkestuen [NDD]
  #5  
Old 16th May 2019, 10:08 AM
David Miller
 
Posts: n/a
Default Re: Need help how to find access violation in code

Any idea how I can stop this? It only happens when they exit the
program. Makes me think it has something to do with house cleaning
that Delphi does when an application closes?

I sometimes create objects using nil instead of application or self.
Could it be related to that? But why wouldn't I see this every time I
exit the program? Why are only some customers reporting the problem and
others seem to have no problem, including me here?


Thorsten Engler [NDA] wrote:

> The red flag here is that it's an access violation AT 00000000
>
> That means this is probably a call against a procedure or method
> pointer that's nil.
>
> The "read" access violation then occurs after the jump when the CPU
> tries to read the next instruction to execute.
>
>
> David Miller wrote:
>
> > I have reports from some clients about the following error message
> > when they exit my application. It does not happen to all my
> > clients, but for those that it does happen, it happens every night
> > when they exit my application.
> >
> > =====
> > Original Application Events Exception: Access violation at address
> > 00000000 in module 'Cap.exe'. Read of address 00000000
> > =====
> >
> > Because of the 00000000, I suspect this error has to do with
> > accessing a null pointer. The problem is that I cannot duplicate
> > the error on my development machine where I can run a debugger. I
> > have tried many times to get my application to give me this error,
> > but it never does. So I can't figure out where in the application
> > the fault lies for creating the error.
> >
> > The weird thing is that if I remotely connect to a clients computer
> > and try to duplicate the error, it does not appear. Only if the
> > application has been in use all day, and the client attempts to exit
> > the application, then the error message appears for them.
> >
> > Can anyone point me in the right direction for how I can locate
> > where in the code this error is happening?




--

  #6  
Old 21st May 2019, 05:59 PM
Ad Franse
 
Posts: n/a
Default Re: Need help how to find access violation in code

Op 15-5-2019 om 23:16 schreef David Miller:

> Can anyone point me in the right direction for how I can locate where
> in the code this error is happening?
>

have a look for :

formxxx := TFormxxx.create( nil )

if there is, free it before exiting the application

if assigned(formxxx) then
begin
formxxx.free;
end;


Ad Franse

---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
https://www.avast.com/antivirus

  #7  
Old 5th June 2019, 08:19 AM
David Miller
 
Posts: n/a
Default Re: Need help how to find access violation in code

Original Application Events Exception: Access violation at address
00000000 in module 'Cap.exe'. Read of address 00000000

I finally found a way to duplicate the error. It seems weird to me.
If I go into a reports area of the application and run a report, then
go into another reports area and run a different report there, then
come back to the main menu area and exit the application, the error
happens. Every time.

So if I break in the IDE when the error message appears, instead of
showing the place in my code, it has a tab called CPU and shows
something like
ippUnknown.ipp.Bof.ippCrackBefore.ippOnCrackAfter. ippOnKey.ippEof.nxsdTy
pes

It looks like something in NexusDB. When I tried to trace before the
error comes up, the last unit that comes up is nxdb.pas and is
positioned in:

procedure TnxDataset.Notification(aComponent : TComponent;
aOperation : TOperation);

I read online that this kind of issue might be releated to the memory
manager, so I tried commenting out nxReplacementMemoryManager which is
the first unit in my project source code. I still get the error, but
now it gives me an address. When I try to find the address, it can't
find it. So I put the nxReplacementMemoryManager back in.

It seems to have all started when I updated to NexusDB 4.12, but that
may just be a coincidence. I setup another machine with NexusDB 4.5005
and using Delphi Tokyo instead of Delphi XE7, also compiled without
packages, but I still have the problem there.

Note that everything seems fine until the application is exited, and
the application exits fine unless two different reports have been run
from different forms in the application. If multiple reports on the
same form have been run, the application still exits fine.

I am still at at loss for how to resolve this problem. I hope somebody
has some ideas. I really need to fix this.


--

  #8  
Old 5th June 2019, 09:06 PM
Michaƫl HUNAULT
 
Posts: n/a
Default Re: Need help how to find access violation in code

Le 04/06/2019 Ć* 23:19, David Miller a Ć©critĀ*:
> Original Application Events Exception: Access violation at address
> 00000000 in module 'Cap.exe'. Read of address 00000000
>
> I finally found a way to duplicate the error. It seems weird to me.
> If I go into a reports area of the application and run a report, then
> go into another reports area and run a different report there, then
> come back to the main menu area and exit the application, the error
> happens. Every time.
>
> So if I break in the IDE when the error message appears, instead of
> showing the place in my code, it has a tab called CPU and shows
> something like
> ippUnknown.ipp.Bof.ippCrackBefore.ippOnCrackAfter. ippOnKey.ippEof.nxsdTy
> pes
>
> It looks like something in NexusDB. When I tried to trace before the
> error comes up, the last unit that comes up is nxdb.pas and is
> positioned in:
>
> procedure TnxDataset.Notification(aComponent : TComponent;
> aOperation : TOperation);
>
> I read online that this kind of issue might be releated to the memory
> manager, so I tried commenting out nxReplacementMemoryManager which is
> the first unit in my project source code. I still get the error, but
> now it gives me an address. When I try to find the address, it can't
> find it. So I put the nxReplacementMemoryManager back in.
>
> It seems to have all started when I updated to NexusDB 4.12, but that
> may just be a coincidence. I setup another machine with NexusDB 4.5005
> and using Delphi Tokyo instead of Delphi XE7, also compiled without
> packages, but I still have the problem there.
>
> Note that everything seems fine until the application is exited, and
> the application exits fine unless two different reports have been run
> from different forms in the application. If multiple reports on the
> same form have been run, the application still exits fine.
>
> I am still at at loss for how to resolve this problem. I hope somebody
> has some ideas. I really need to fix this.
>
>

Hi David,

when a component is destroyed, it notifies all the components in his
free notification list that it is destroyed. In your case, you may have
a component referenced in this free notification list that has already
been destroyed and not removed from this free notification list.

In your report tools do you keep references to external component ?
If yes, you should handle free notifications and do something like:

TMyReportTool = class(...)
protected
...
procedure Notification(AComponent: TComponent; Operation:
TOperation); override;
public
property MyComponent: TSomeComponent read FMyComponent write
SetMyComponent;
...
end;

procedure TMyReportTool.SetMyComponent(Value: TSomeComponent);
begin
if FMyComponent <> Value then
begin
// we do not need to be notified anymore when this old component
will be destroyed (we will have no more reference to it)
if Assigned(FMyComponent) then
FMyComponent.RemoveFreeNotification(Self);

FMyComponent := Value;

// ask to be notified when this new component will be destroyed
elsewhere
if Assigned(FMyComponent) then
FMyComponent.FreeNotification(Self);
end;
end;

procedure TMyReportTool.Notification(AComponent: TComponent; Operation:
TOperation);
begin
inherited;

if (Operation = opRemove) and (AComponent <> nil) then
begin
// If MyComponent has been is destroyed elsewhere, do not keep an
invalid reference to it (inherited will remove it from the free
notification list).
if AComponent = FMyComponent then
FMyComponent := nil;
end;
end;

and of course if FMyComponent is nil do not use it ;o)

And if you already do this kind of things, perhaps you have forgotten
one somewhere.

Hope it helps.

--
Michaƫl

  #9  
Old 8th June 2019, 10:05 AM
David Miller
 
Posts: n/a
Default Re: Need help how to find access violation in code

Michaƫl HUNAULT wrote:
> In your report tools do you keep references to external component ?
> If yes, you should handle free notifications and do something like:


I use Report Builder for reporting and I do not reference external
components.

One odd thing about this is that I can run several reports from the
same form giving access to the reports and there are no problems. But
if I run a report from one form, then close that form and run a report
from another form, then when closing the application, the error appears.

I have a full error report from Mad Except but I don't know how to read
it to track down the error.

David.



--

  #10  
Old 21st June 2019, 08:19 AM
David Miller
 
Posts: n/a
Default Re: Need help how to find access violation in code

I seemed to have fixed the problem by changing the order of creation of
my data modules so that they are created before the forms that use them
are created (the data modules and forms are created when the
application starts up and are not explicitly freed when the application
is exited). I am not sure why this fixes it, but I do not seem to get
the access violation anymore. Thank you all for your help.


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Violation David Rose nexusdb.public.support 16 25th November 2016 02:00 AM
Access Violation David Rose nexusdb.public.support 2 12th February 2015 10:15 PM
EM V2 access violation Roberto Nicchi nexusdb.public.support 1 6th April 2009 11:13 PM
Re: Access Violation Eivind Bakkestuen [NDD] nexusdb.public.support 1 29th May 2007 02:11 AM
v2.02 Access Violation David Charron nexusdb.public.support.sql 1 14th September 2005 12:30 PM


All times are GMT +11. The time now is 03:51 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.