Access violation Einvalide Pointe on some computers

Posted on 2005-04-01
Medium Priority
Last Modified: 2007-12-19
My delphi 7 program is working stable and nice, but on some very few computes, like my new siemens laptop, it is not working at all.
I got an EinvalidPointer and several access violations. I have not installed delphi 7 and my source on that machine.  I guess I have memory problem and it is related to som drivers on this pc. Like screen driver etc.

I have tried eureka log but  only get references to ntdll.dll (ZWsetinformationthread)
and that error i cannot tace.

Customers have claimed this error on all OS version and I got it here on WIN NT4 and Xl.

My question is, how can I track such errors, and how can I find that component or driver that makes this error?

Kind regards
Bjarte Dyngjeland
Question by:dygj
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +2
LVL 19

Assisted Solution

Barthax earned 501 total points
ID: 13681236
An EInvalidPointer is typically due to your program referencing some variable that no longer exists.  I would not expect to find that the error is being caused by some piece of hardware or it's drivers unless you are specifically writing low-level interfacing to the hardware.

If you are not already aware, an EInvalidPointer is a member of the Exception series of sub-classes and as such can be trapped with a try...except style statement.  As the product is your own, I imagine you can ascertain what stage you program may be at when you/your customer is experiencing the problem.  From this you should be able to decipher at which point in your code you are likely to be experiencing the problem & you begin to put in the try...excepts in the form of:

  <your code that you suspect may be causing the EInvliadPointer>
    On EInvalidPointer do
        <put some code in here for your added diagnostics>

LVL 12

Assisted Solution

andrewjb earned 498 total points
ID: 13682164
Someone's bound to mention MadExcept in a minute....

(Worth a go!)
LVL 19

Expert Comment

ID: 13685654
Thanks for the pointer Andrew, didn't know it existed myself. :) http://help.madshi.net/madExcept.htm
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 31

Expert Comment

by:Wayne Barron
ID: 13686695
Read the description on the MadExcept, and it seems like a great program
To have especially in a project that is going to be used by a lot of people.

Thanks again for the link.

Author Comment

ID: 13695790
I have downloaded maxexcept, and got an exception log. Thanks for that link.
I restarted my computer and started my application, and close it without doing anything. Now I got invalide pointer  closeing my application. In my onclose and onclosequery on my main form I do not get an normally exception so I expect the error to happen after all my  work is done?

From the error log, I guess this line indicates the problem
00402c0f > call    +$184 ($402d98)        ; Error

Searching in my source after the adresses abowe dont give my I clue, so my querstion is; how can I find this error in my source?

Extract from error log:
date/time         : 2005-04-04, 09:31:14, 938ms

operating system  : Windows XP Service Pack 2 build 2600
system up time    : 4 minutes 25 seconds
program up time   : 16 seconds
processor         : Intel(R) Pentium(R) M processor 1.60GHz
physical memory   : 688/1014 MB (free/total)
display mode      : 1024x768, 32 bit
process id        : $ab4
allocated memory  : 13,24 MB
executable        : timing18.exe
bde version       :
madExcept version : 2.7g
exception class   : EInvalidPointer
exception message : Invalid pointer operation.

main thread ($ab8):
00402c0f timing18.exe System            @FreeMem
00404800 timing18.exe System            TObject.FreeInstance
00404c0a timing18.exe System            @ClassDestroy
004cd04b timing18.exe Menus             TMenuItem.Destroy
0045315e timing18.exe Classes           TComponent.DestroyComponents
00452f63 timing18.exe Classes           TComponent.Destroy
004bb4d7 timing18.exe Controls          TControl.Destroy
004beae1 timing18.exe Controls          TWinControl.Destroy
004d5730 timing18.exe Forms             TScrollingWinControl.Destroy
004d640b timing18.exe Forms             TCustomForm.Destroy
0045315e timing18.exe Classes           TComponent.DestroyComponents
004d45c7 timing18.exe Forms             DoneApplication
00433295 timing18.exe SysUtils          DoExitProc
00405617 timing18.exe System            @Halt0
00932435 timing18.exe timing18 362 +148 initialization

thread $b04: <priority:1>
7c90eb94 ntdll.dll     KiFastSystemCallRet
7c90e9be ntdll.dll     NtWaitForSingleObject
7c8025d5 kernel32.dll  WaitForSingleObjectEx
7c80253d kernel32.dll  WaitForSingleObject

thread $a4c: <priority:1>
7c90eb94 ntdll.dll     KiFastSystemCallRet
7c90e9be ntdll.dll     NtWaitForSingleObject
7c8025d5 kernel32.dll  WaitForSingleObjectEx
7c80253d kernel32.dll  WaitForSingleObject

thread $b14: <priority:1>
7c90eb94 ntdll.dll     KiFastSystemCallRet
7c90e9be ntdll.dll     NtWaitForSingleObject
7c8025d5 kernel32.dll  WaitForSingleObjectEx
7c80253d kernel32.dll  WaitForSingleObject

00400000 timing18.exe          W:
01b40000 Vxdif.dll    5.3.401.42       C:\WINDOWS\system32
01c90000 MSJTER35.DLL 3.51.623.0       C:\WINDOWS\system32
01f80000 MSJINT35.dll 3.51.623.0       C:\WINDOWS\system32
04030000 dao350.dll   3.51.1027.0      c:\programfiler\fellesfiler\microsoft shared\DAO
040d0000 MSJET35.DLL  3.51.623.4       C:\WINDOWS\system32
08a10000 vbar332.dll       C:\WINDOWS\system32
10000000 Apoint.DLL   5.3.401.158      C:\Programfiler\Apoint2K
20000000 odbcint.dll  3.525.1117.0     C:\WINDOWS\system32
4bde0000 IDAPI32.DLL          C:\Programfiler\Borland\Common Files\BDE
4c5e0000 idsql32.DLL          C:\Programfiler\Borland\Common Files\BDE
4c9e0000 IDR20009.DLL          C:\Programfiler\Borland\Common Files\BDE
4e5e0000 IDDA3532.DLL          C:\Programfiler\Borland\Common Files\BDE
4e8e0000 BANTAM.DLL          C:\Programfiler\Borland\Common Files\BDE
5b290000 uxtheme.dll  6.0.2900.2180    C:\WINDOWS\system32
5d5d0000 comctl32.dll 5.82.2900.2180   C:\WINDOWS\system32
5f310000 olepro32.dll 5.1.2600.2180    C:\WINDOWS\system32
71a90000 WS2HELP.dll  5.1.2600.2180    C:\WINDOWS\system32
71aa0000 WS2_32.dll   5.1.2600.2180    C:\WINDOWS\system32
71ac0000 wsock32.dll  5.1.2600.2180    C:\WINDOWS\system32
71b10000 mpr.dll      5.1.2600.2180    C:\WINDOWS\system32
72fd0000 winspool.drv 5.1.2600.2180    C:\WINDOWS\system32
746f0000 MSCTF.dll    5.1.2600.2180    C:\WINDOWS\system32
74780000 odbc32.DLL   3.525.1117.0     C:\WINDOWS\system32
74ab0000 cfgmgr32.dll 5.1.2600.2180    C:\WINDOWS\system32
74e00000 RICHED20.DLL     C:\WINDOWS\system32
75e70000 SXS.DLL      5.1.2600.2180    C:\WINDOWS\system32
76370000 imm32.dll    5.1.2600.2180    C:\WINDOWS\system32
76390000 comdlg32.dll 6.0.2900.2180    C:\WINDOWS\system32
76830000 UNIDRVUI.DLL 0.3.1296.1       C:\WINDOWS\System32\spool\DRIVERS\W32X86\3
76b30000 winmm.dll    5.1.2600.2180    C:\WINDOWS\system32
76fc0000 CLBCATQ.DLL  2001.12.4414.258 C:\WINDOWS\system32
77040000 COMRes.dll   2001.12.4414.258 C:\WINDOWS\system32
77110000 oleaut32.dll 5.1.2600.2180    C:\WINDOWS\system32
773c0000 comctl32.dll 6.0.2900.2180    C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9
774d0000 ole32.dll    5.1.2600.2595    C:\WINDOWS\system32
778c0000 UNIDRV.DLL   0.3.1296.4       C:\WINDOWS\System32\spool\DRIVERS\W32X86\3
77910000 setupapi.dll 5.1.2600.2180    C:\WINDOWS\system32
77bf0000 version.dll  5.1.2600.2180    C:\WINDOWS\system32
77c00000 msvcrt.dll   7.0.2600.2180    C:\WINDOWS\system32
77d30000 user32.dll   5.1.2600.2180    C:\WINDOWS\system32
77dc0000 advapi32.dll 5.1.2600.2180    C:\WINDOWS\system32
77e70000 RPCRT4.dll   5.1.2600.2180    C:\WINDOWS\system32
77f10000 GDI32.dll    5.1.2600.2180    C:\WINDOWS\system32
77f60000 SHLWAPI.dll  6.0.2900.2573    C:\WINDOWS\system32
77fe0000 Secur32.dll  5.1.2600.2180    C:\WINDOWS\system32
78080000 MSVCRT40.dll 5.1.2600.2180    C:\WINDOWS\system32
7c800000 kernel32.dll 5.1.2600.2180    C:\WINDOWS\system32
7c900000 ntdll.dll    5.1.2600.2180    C:\WINDOWS\system32
7c9c0000 shell32.dll  6.0.2900.2578    C:\WINDOWS\system32

00402c01   call    dword ptr [$933048]    ; SysFreeMem
00402c07   mov     ebx, eax
00402c09   test    ebx, ebx
00402c0b   jz      loc_402c18
00402c0d   mov     al, 2
00402c0f > call    +$184 ($402d98)        ; Error
00402c14   jmp     loc_402c18
00402c16   xor     ebx, ebx
00402c18   mov     eax, ebx
00402c1a   pop     ebx
00402c1b   ret

LVL 20

Accepted Solution

Madshi earned 501 total points
ID: 13695843
The exception is raised during shutdown of your application. Delphi automatically frees all forms it knows of and which it thinks are not freed yet. During this the exception is raised. Your own source code is not directly involved in this. But probably your code is somewhat guilty here, nevertheless (just indirectly).

Do you create some forms yourself by calling TSomeForm.Create or TSomeForm.CreateNew? If so, what do you give in as the owner? "Application" or "nil"? Try freeing those forms manually before your application shuts down. Or if you already free them, try not freeing them yourself.

I guess Delphi tries to free a form, which was already freed. Or maybe it frees a form too late, for whatever reason.
LVL 19

Expert Comment

ID: 13696342
> I guess Delphi tries to free a form, which was already freed. Or maybe it frees a form too late, for whatever reason.

Very likely that the form has already been freed in my experience.  Check all occurences of your code where you free a form and check how you are using the variable after the form is freed.  If you are not already using it, FreeAndNil(<object>) is probably the safest method of freeing any object in memory - it still isn't full proof though.  For example:

procedure IWillCrash;
  myform, myform2: TForm;
  myform := TForm.Create;
  myform2 := myform;

The pointer that myform2 is using (all objects variables are just pointers used in a particular way) is referencing an area of memory that no longer is a valid form.  This will cause an invalid pointer error.  You likely have the same scenario, just not so localised. :)

Author Comment

ID: 13697279
I'm normally using myform.create(application)  but for this error it seems not to make any differences if I use self/nil. (And i'm doing myform.free or setting action:=ccfree then closing created forms. )

The main problem is that I'm only getting this error on a very few pc's.
I have started my application several times witd mad exceptions on, and somethimes I got an error on RXTimer (112+2) in ttimertread. I have gone trough all my timers and enshured that all of them is deactivated.

Must be some way of finding out the last object delphi frees before creating the crash? or name of the object that create the error ?

LVL 20

Expert Comment

ID: 13697336
If you can reproduce the problem on your PC, you can compile with debug DCUs and set breakpoints in the debugger. But if you can't reproduce it, things get much more difficult.

Do you really need these threaded timers? I don't like threaded timers at all. Why don't you use normal timers instead? When thread are still running although your application is already shutting down, things can go crazy.
LVL 19

Expert Comment

ID: 13697414
Now you've introduced threads into the problem, you face the necessity of ensuring that all threads are shut down before your program attempts to exit.  Just one of the possible problems you face is a timer thread waking up after the form it's about to reference is already unloaded. :(  That will certainly cause an EInvalidPointer exception.

Author Comment

ID: 13917977
I have installed this source and delphi 7 on the laptop making all the problems. Still getting the invalid pointer. I removed all timers so it should be only one tread left.

I got this error then delphi is destroying components on my mainform, the first one i notice was a indexdef.free that crashed as long as master detalj relationship was enabeld. Removing the relationship gave me no error there, but the error moved to another place.

The error always have the same adress and it is in the freemem function. Anyway I cannnot figure out why it is crashing.

Could it possble be a version problem with ttoolbar??
Bjarte Dyngjeland

Author Comment

ID: 14239985
Finaly found the error: It happens in the function below, on some computers and I am  assuming the user name beeing  too long. Te error occures then I close my application, not when the function is called.

I found the error after deleting all functions/procedures until my application worked.
Still unhappy with not beeing able to find this error with  any debugging tools.

Unshure that to do with the points, That is normal ? Splitt them between all who tried to help me?

Anyway thaks for your efforts.  

function GetMyNetUserName: string;

   SetLength(a, dbiMaxUserNameLen + 1);
   SetLength(Result, StrLen(PChar(a)));

LVL 19

Expert Comment

ID: 14240343
Glad you got it sorted. :)

There's a section in the help on how to close questions: http://www.experts-exchange.com/help.jsp#hs5

If you found any answers actually helpful, then I'd suggest assigning to them, but it looks to me that a refund would be in order. :)

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question