access violation

前几天,在公司遇到程序编译顺利通过,头一天运行良好,第二天早上就出现了“初始化失败”的现象,到网上搜索,无果,最终重新装了系统,问题得以解决。今天在宿舍又出现同样情况,我决心努力解决。以下为从国外网站论坛,作为笔记,以备查阅:

   

11-12-2003, 05:24 PM
hi,
I am programming National instruments data aquisition system using VC++.
My code builds up fine but i get the following error while executiion:
Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/KERNEL32.DLL', no matching symbolic information found.
Loaded 'C:/Documents and Settings/Raman Mathur/My Documents/C++/EXDET1/ExDet1012/Debug/dio64_32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/user32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/GDI32.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/ADVAPI32.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/rpcrt4.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/MFC42D.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/MSVCRTD.DLL', no matching symbolic information found.
Loaded symbols for 'C:/WINDOWS/SYSTEM32/MFCO42D.DLL'
Loaded 'C:/WINDOWS/SYSTEM32/OLEAUT32.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/MSVCRT.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/ole32.dll', no matching symbolic information found.
Loaded 'C:/vxipnp/winnt/Bin/niFgen_32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nispylog.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/MSVCP60.DLL', no matching symbolic information found.
Loaded 'C:/vxipnp/winnt/Bin/niscope_32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nicfq32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nipsm.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/WSOCK32.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/ws2_32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/WS2HELP.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nirpc.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nidaq32.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nipalu.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nipalut.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/niSTCu.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nibffru.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/nimdsu.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/NIScale.dll', no matching symbolic information found.
Loaded symbols for 'C:/WINDOWS/SYSTEM32/MSVCIRTD.DLL'
Loaded 'C:/WINDOWS/SYSTEM32/OLEPRO32.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/MSVCP60D.DLL', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/dio64_nt.dll', no matching symbolic information found.
Loaded 'C:/WINDOWS/SYSTEM32/SETUPAPI.DLL', no matching symbolic information found.
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:/WINDOWS/SYSTEM32/UXTHEME.DLL', no matching symbolic information found.
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:/WINDOWS/SYSTEM32/UXTHEME.DLL', no matching symbolic information found.
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:/WINDOWS/SYSTEM32/UXTHEME.DLL', no matching symbolic information found.
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:/WINDOWS/SYSTEM32/UXTHEME.DLL', no matching symbolic information found.
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000005: Access Violation.
Loaded 'C:/WINDOWS/SYSTEM32/CTAGENT.DLL', no matching symbolic information found.
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
-----------------------------------------------------
I have no idea what is going on.....Please suggest

vicodin451
11-12-2003, 09:27 PM
First-chance exceptions should always be investigated/explored. You can do the following to get your code to "break" on a first-chance access violation:

-Start debugging your EXE.
-From the "Debug" menu, choose "Exceptions...".
-Find "c0000005 - Access Violation" in the "Exceptions" list box
-Choose "Stop always" in the Action section.
-Click "Change"
-Click OK

Depending on how far your app got by the time you have done this, you may need to restart the debugging session.

When you do, the application will "break" at the first first-chance access violation. Examine the call stack and ensure that everything is as expected. If they aren't, figure out what's wrong. If they are, continue debugging - each first-chance access violation will cause a "break" in the debugger. For each one, make sure that things are as expected. When you have done this, you can change the setting for c0000005 back to "Stop if not handled" in the Debug | Exceptions dialog.

The
First-chance exception in ExDet.exe (NTDLL.DLL): 0xC0000142: DLL Initialization Failed.
indicates that DllMain is returning 0. I would suggest getting to the bottom of the access violations before tackling this one, though. The AVs and the failure to initialize the DLL are likely related...

rmathur
11-14-2003, 12:46 PM
Hi,
Thanks for your reply.
Unfortunately I am not a software major and don't understand the details about the call stack.
I did look into the call stack and sending you what i see.
This is the first time the Access Violation occurs.
Can you suggest something?
Thanks for your help.
Raman
--------------------------------------------------------------------

->NTDLL! 77f57bd2()
MSVCRT! 77c2ac14()
MSVCRT! 77c2ac2a()
NTDLL! 77f5b42c()
NTDLL! 77f56771()
NTDLL! 77f6151e()
NTDLL! 77f570e0()
KERNEL32! 77e7d901()
KERNEL32! 77e7d95e()
DIO64_32! 10002050()
NTDLL! 77f5b42c()
NTDLL! 77f56771()
NTDLL! 77f649a8()
00020000()

vicodin451
11-14-2003, 01:46 PM
Hi,
Thanks for your reply.
Unfortunately I am not a software major and don't understand the details about the call stack.
I did look into the call stack and sending you what i see.
This is the first time the Access Violation occurs.
Can you suggest something?
Thanks for your help.
Raman
--------------------------------------------------------------------

->NTDLL! 77f57bd2()
MSVCRT! 77c2ac14()
MSVCRT! 77c2ac2a()
NTDLL! 77f5b42c()
NTDLL! 77f56771()
NTDLL! 77f6151e()
NTDLL! 77f570e0()
KERNEL32! 77e7d901()
KERNEL32! 77e7d95e()
DIO64_32! 10002050()
NTDLL! 77f5b42c()
NTDLL! 77f56771()
NTDLL! 77f649a8()
00020000()



Is the stack you posted from a debug or a release build of your application?
You could install the symbols... see PSS ID Number 296110 (INFO: How to Install the Debug Symbols for Use with Visual Studio Products) in the MSKB for instructions. This will hopefully give more "textual" information...

Another thing that may be helpful is a profile from DependencyWalker.
-Download DependencyWalker from www.DependencyWalker.com.
-Run DEPENDS.EXE.
-Open your exe and choose Profile | Start Profiling.
-Check every box in the dialog except for "Use simple thread numbers instead of actual thread IDs.".
-Click "OK".
When the app is done, choose File | Save As..., and save the Dependency Walker Image. ZIP up the image and post it.

phone_guy
11-14-2003, 02:14 PM
rmathur,

Does your ExDet.exe program contain any customized message maps? Last time I had this error it was an incorrect definition of a function that used message mapping macros.

Regards.

vicodin451
11-14-2003, 02:18 PM
Originally posted by phone_guy
rmathur,

Does your ExDet.exe program contain any customized message maps? Last time I had this error it was an incorrect definition of a function that used message mapping macros.

Regards.

FWIW, there are many ways to cause an attempt to access memory that shouldn't be accessed.

vicodin451
11-15-2003, 03:23 PM
What are DIO64_NT.DLL and DIO64_32.DLL? Do you have the source for these?

00:00:00.359: LoadLibraryA("Dio64_NT.dll") called from "c:/documents and settings/raman mathur/my documents/c++/exdet1/exdet1012/debug/DIO64_32.DLL" at address 0x10001194 by thread 0xC90.
00:00:00.359: Loaded "c:/windows/system32/DIO64_NT.DLL" at address 0x00390000 by thread 0xC90. Successfully hooked module.
00:00:00.375: Loaded "c:/windows/system32/SETUPAPI.DLL" at address 0x76670000 by thread 0xC90. Successfully hooked module.
00:00:00.375: DllMain(0x76670000, DLL_PROCESS_ATTACH, 0x00000000) in "c:/windows/system32/SETUPAPI.DLL" called by thread 0xC90.
00:00:00.375: First chance exception 0xC0000005 (Access Violation) occurred in "c:/windows/system32/NTDLL.DLL" at address 0x77F57BD2 by thread 0xC90.
00:00:00.375: Unloaded "c:/windows/system32/DIO64_NT.DLL" at address 0x00390000 by thread 0xC90.
00:00:00.375: Unloaded "c:/windows/system32/SETUPAPI.DLL" at address 0x76670000 by thread 0xC90.
00:00:00.375: LoadLibraryA("Dio64_NT.dll") returned NULL by thread 0xC90. Error: Invalid access to memory location (998).
Looks like something done by DllMain (directly or indirectly) in Dio64_NT.DLL is causing the (a) problem.

What CRT is EXDET.EXE using? (Project | Settings | C/C++ | Code Generation | Use runtime library)

rmathur
11-17-2003, 07:37 PM
Dio64_NT.dll and Dio64_32.dll are the dll's supplied to me by Viewpoint Systems.
I am programming a PXI card (A digital IO 64 bit card) in this application which is manufactured by Viewpoint.
I dont have the source for these but i am attaching the dll itself if that helps.
The CRT i am using is " Debug Multithreaded DLL".
Thank You.
-Raman

vicodin451
11-17-2003, 09:16 PM
Based on the call stack you gave earlier, these are the "closest" symbols I'm able to get:

NTDLL! 77f57bd2() - RtlAllocateHeap
MSVCRT! 77c2ac14() - free
MSVCRT! 77c2ac2a() - free
NTDLL! 77f5b42c() - LdrInitializeThunk
NTDLL! 77f56771() - RtlCreateHeap
NTDLL! 77f6151e() - LdrGetProcedureAddress
NTDLL! 77f570e0() - LdrLoadDll
KERNEL32! 77e7d901() - LoadLibraryExW
KERNEL32! 77e7d95e() - LoadLibraryExA
DIO64_32! 10002050() - DIO64_Close [far away - perhaps DllMain in DIO64_32?)
NTDLL! 77f5b42c() - LdrInitializeThunk
NTDLL! 77f56771() - RtlCreateHeap
NTDLL! 77f649a8() - LdrShutdownThread
00020000() - ?


It _almost_ looks like DIO64_32.DLL is calling LoadLibrary in DllMain - a big no-no.

Have you checked with "Viewpoint Systems" to verify this stuff runs under XP?

Are you calling LoadLibrary("Dio64_NT.dll") anywhere in your code? The DW profile doesn't seem to indicate that. It really looks like DIO64_32.dll calls LoadLibrary on Dio64_NT.DLL, possibly from DllMain.

00:00:00.359: LoadLibraryA("Dio64_NT.dll") called from "c:/documents and settings/raman mathur/my documents/c++/exdet1/exdet1012/debug/DIO64_32.DLL" at address 0x10001194 by thread 0xC90.

It looks like your EXE only calls DIO64_Open at this point. If you "fake" success for the call, and comment the call to DIO64_Open out, does your app still blow up? Also, in another test, can you pause your app (message box?) just before DIO64_Open, and just after it, and note what output was added to DependencyWalker's output window between the pauses?

rmathur
11-19-2003, 04:27 PM
I am not able to put a break before and after the DIO64_Open(). It gives the same error message while execution" DIO64_NT.dll" not loaded".
If i comment out the call DIO64_Open(), and no other functions for DIO are called, everything works fine. No errors.
Does it provide any clue?
Thanks
-Raman

vicodin451
11-19-2003, 09:52 PM
Originally posted by rmathur
I am not able to put a break before and after the DIO64_Open(). It gives the same error message while execution" DIO64_NT.dll" not loaded".
You can set a breakpoint without having started the app. Are you saying you did this, and the breakpoint was not reached before you got the error message?


If i comment out the call DIO64_Open(), and no other functions for DIO are called, everything works fine. No errors.
This is likely because DllMain isn't being called, because no functions in DIO64_32 are called, so there's no need to load the library.

One thought:
In ViewPoint and ArbitraryWaveformExample, DIO64_32.DLL was loaded from "c:/windows/system32/". But in ExDet, it is loading from "c:/documents and settings/raman mathur/my documents/c++/exdet1/exdet1012/debug/"
Perhaps you can try ExDet, but have it use the DIO64_32.DLL in C:/Windows/System32 (not that this _should_ make a difference, but DIO64_NT.DLL lives in System32, and is referenced there in all three modules.

At any rate, it looks like you have 2 projects that work just fine with DIO64, and 1 that does not. Perhaps you could compare settings between a project that works with DIO64, and the one that does not work with DIO64... Up to the failure, are the functions in DIO64_32.DLL being called in the same order by both the app that works, and the one that fails? (It looks like ExDet only calls DIO64_Open - does another app [that works] call something prior to DIO64_Open?)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值