Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(MSVCRT.DLL): 0xC0000005: Access Violation

3,548 views
Skip to first unread message

H

unread,
Mar 19, 2004, 12:28:17 AM3/19/04
to
Hi All,

I'm using Visual Studio 6 to develop a C/C++ application and currently
receiving the following error:

First-chance exception in test.exe (MSVCRT.DLL): 0xC0000005: Access
Violation.

I've spent weeks trying to figure out what the real problem was but
still unable to find the cause. Can someone please help me out. Why
this exception, what cause it and how to fix it?

By the way, my program is an example code for extending the Active
Directory schema programmatically from msdn =>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/example_code_for_extending_the_schema_programmatically.asp

Any help or suggestion is greatly appreciated!

Thanks,
H.

David Lowndes

unread,
Mar 19, 2004, 9:33:32 AM3/19/04
to
>I'm using Visual Studio 6 to develop a C/C++ application and currently
>receiving the following error:
>
>First-chance exception in test.exe (MSVCRT.DLL): 0xC0000005: Access
>Violation.
>
>I've spent weeks trying to figure out what the real problem was but
>still unable to find the cause.

Is this actually causing you a problem, does your application crash as
a result of it?

Have a look at PSS ID Number: 105675 "INFO: First and Second Chance
Exception Handling".

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq

Ivan Brugiolo [MSFT]

unread,
Mar 19, 2004, 11:29:27 AM3/19/04
to
It can be cause by a heap corruption.
Try enabling PageHeap on your executable, and running your application under
debugger all the time

c:\debuggers>gflags /p /enable YourApp.exe /fulle
c:\debugger>start cdb -g -G YourApp.exe

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"H" <vth...@yahoo.com.au> wrote in message
news:83a71140.04031...@posting.google.com...

H

unread,
Mar 21, 2004, 6:58:46 PM3/21/04
to
Hi All,

Thank you very much for both of your responses and help.

First of all (in order as listed) to David, yes this is the actual
problem. The applilcation compiles fine, but when run crashes with
that error. Thank you for pointing to the article regarding 1st and
2nd chance exceptions. It was useful to know.

To Ivan: i haven't use C++ extensively so please bare with some of my
trivial questions. I followed your instruction to enable Page heap.
The first line (c:\Program Files\Microsoft Script Debugger>gflags /p
/enable test.exe /fulle) was fine. But the second instruction
(c:\Program Files\Microsoft Script Debugger>start cdb -g -G test.exe)
failed with an error saying that Windows cannot find 'cdb'.

Ivan, is the debugger i'm using (Program Files\Microsoft Script
Debugger) the same as the one you are rerefering to?

What does the 2nd instruction "Debugger>start cdb -g -G test.exe"
actually do (i assumed starting the app in debugger mode)?

If i run my application under the debugger all the time as you
suggested, will this cause any problem when i deploy the application
to my client running in the Windows environment?

Once again thank you for your help and looking forward for your next
response (can't wait to nail down this frustrating problem!).

H.

"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> wrote in message news:<O6Jue#cDEHA...@TK2MSFTNGP11.phx.gbl>...

ak com>

unread,
Mar 22, 2004, 7:11:37 AM3/22/04
to
On 21 Mar 2004 15:58:46 -0800, vth...@yahoo.com.au (H) wrote:

>>>
>>> "H" <vth...@yahoo.com.au> wrote in message
>>> news:83a71140.04031...@posting.google.com...
>>> > Hi All,
>>> >
>>> > I'm using Visual Studio 6 to develop a C/C++ application and
currently
>>> > receiving the following error:
>>> >
>>> > First-chance exception in test.exe (MSVCRT.DLL): 0xC0000005:
Access
>>> > Violation.
>>> >
>>> > I've spent weeks trying to figure out what the real problem was
>>> but still unable to find the cause. Can someone please help me
out. Why this exception, what cause it and how to fix it?
>>> >
>>> > By the way, my program is an example code for extending the
Active
>>> > Directory schema programmatically from msdn =>
>>> >
>>>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ad/ad/example_code_for_extending_the_schema_programmatically.asp
>>> >
>>> > Any help or suggestion is greatly appreciated!
>>> >
>>> > Thanks,
>>> > H.

>>Hi All,
>>
>>Thank you very much for both of your responses and help.
>>
>>First of all (in order as listed) to David, yes this is the actual
>>problem. The applilcation compiles fine, but when run crashes with
>>that error. Thank you for pointing to the article regarding 1st and
>>2nd chance exceptions. It was useful to know.
>>
>>To Ivan: i haven't use C++ extensively so please bare with some of
my
>>trivial questions. I followed your instruction to enable Page heap.
>>The first line (c:\Program Files\Microsoft Script Debugger>gflags /p
>>/enable test.exe /fulle) was fine. But the second instruction
>>(c:\Program Files\Microsoft Script Debugger>start cdb -g -G
test.exe)
>>failed with an error saying that Windows cannot find 'cdb'.
>>
>>Ivan, is the debugger i'm using (Program Files\Microsoft Script
>>Debugger) the same as the one you are rerefering to?
>>
>>What does the 2nd instruction "Debugger>start cdb -g -G test.exe"
>>actually do (i assumed starting the app in debugger mode)?
>>
>>If i run my application under the debugger all the time as you
>>suggested, will this cause any problem when i deploy the application
>>to my client running in the Windows environment?
>>
>>Once again thank you for your help and looking forward for your next
>>response (can't wait to nail down this frustrating problem!).
>>

Ok there could be a number of reasons; although to me it sounds
as you have a null ptr somewhere - I looked at the link you
posted and would suggest that you check all return codes and ptrs
using assert ATLASSERT or whatever your env is.

You can also force the program to check the heap by each allocation
using a flag - check your online help for _CrtSetDbgFlag then maybe
you be able to catch it as it happens. Also I saw that your having a
multi-thread program so synchronization could also be a cause for such
an error. Make sure you have critical sections around shared areas.

hth a bit
/ak


Ivan Brugiolo [MSFT]

unread,
Mar 22, 2004, 12:27:38 PM3/22/04
to
cdb.exe is one of the standard debuggers oyu can download from
http://www.microsoft.com/whdc/ddk/debugging/default.mspx
Since the package above includes the most recent gflags.exe,
I had assumed that if you had the first one (gflags.exe)
you would have had the second (cdb.exe) as well.
The debugger you will be using does not really matter.
You can use devenv.exe, if you are comfortable with it.
But, you have to keep in mind that cdb/ntsd/windbg comes with
debugger extensions designed to help diagnose
the Acccess Violation (and other breakpoints)
enforced and caused by PageHeap.

Running the application under debugger should be
limited accurrence till the problem is understood and resolved.
I'm not aware of any software installation that requires
the applicaiton being debugged all the time.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"H" <vth...@yahoo.com.au> wrote in message

news:83a71140.04032...@posting.google.com...

Ivan Brugiolo [MSFT]

unread,
Mar 22, 2004, 9:59:44 PM3/22/04
to
This looks an old-plain access violation on an invalid pointer.
If you could report the output of the `~*kb' command
at the time of the exception, maybe we could help.
From the debug spew below, the problem seems with the parm
passed to wcslen more than with the wcslen itself.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"H" <vth...@yahoo.com.au> wrote in message
news:83a71140.04032...@posting.google.com...
> Hi All,
>

> Once again, thank you for your responses.
>
> Ivan, i downloaded the tool and got this list generated by the
> debugger below. I've got no idea what it's saying but suspect there
> may be something wrong with wcslen() as indicated. Will you be able to
> interpret these please? Thanks Ivan.
>
> Microsoft (R) Windows Debugger Version 6.3.0011.2
> Copyright (c) Microsoft Corporation. All rights reserved.
>
> CommandLine: c:\documents and
> settings\administrator\desktop\adsibasics\debug\test.exe
> Symbol search path is: *** Invalid ***
>
****************************************************************************
> * Symbol loading may be unreliable without a symbol search path.
> *
> * Use .symfix to have the debugger choose a symbol path.
> *
> * After setting your symbol path, use .reload to refresh symbol
> locations. *
>
****************************************************************************
> Executable search path is:
> ModLoad: 00400000 0040e000 test.exe
> ModLoad: 77f40000 77ffa000 ntdll.dll
> Page heap: pid 0xFD4: page heap enabled with flags 0x2.
> ModLoad: 77e40000 77f34000 C:\WINNT\system32\kernel32.dll
> ModLoad: 77da0000 77e30000 C:\WINNT\system32\ADVAPI32.dll
> ModLoad: 77c50000 77cf4000 C:\WINNT\system32\RPCRT4.dll
> ModLoad: 77160000 77284000 C:\WINNT\system32\ole32.dll
> ModLoad: 77ba0000 77bf4000 C:\WINNT\system32\msvcrt.dll
> ModLoad: 77c00000 77c44000 C:\WINNT\system32\GDI32.dll
> ModLoad: 77d00000 77d8f000 C:\WINNT\system32\USER32.dll
> ModLoad: 770e0000 7715d000 C:\WINNT\system32\OLEAUT32.dll
> ModLoad: 76df0000 76e22000 C:\WINNT\system32\ACTIVEDS.dll
> ModLoad: 76dc0000 76de6000 C:\WINNT\system32\adsldpc.dll
> ModLoad: 71c40000 71c93000 C:\WINNT\system32\NETAPI32.dll
> ModLoad: 76f10000 76f3f000 C:\WINNT\system32\WLDAP32.dll
> ModLoad: 76b80000 76bad000 C:\WINNT\system32\credui.dll
> ModLoad: 77380000 77b5d000 C:\WINNT\system32\SHELL32.dll
> ModLoad: 77290000 772d9000 C:\WINNT\system32\SHLWAPI.dll
> ModLoad: 76a80000 76a98000 C:\WINNT\system32\ATL.DLL
> ModLoad: 10480000 104fe000 C:\WINNT\system32\MSVCP60D.dll
> ModLoad: 10200000 10260000 C:\WINNT\system32\MSVCRTD.dll
> ModLoad: 71c20000 71c31000 C:\WINNT\system32\tsappcmp.dll
> ModLoad: 70ad0000 70bb6000
> C:\WINNT\WinSxS\x86_Microsoft.Windows.Common-Contro
> ls_6595b64144ccf1df_6.0.100.0_x-ww_8417450B\comctl32.dll
> ModLoad: 76f90000 7700e000 C:\WINNT\system32\CLBCatQ.DLL
> ModLoad: 77010000 770d6000 C:\WINNT\system32\COMRes.dll
> ModLoad: 77b90000 77b98000 C:\WINNT\system32\VERSION.dll
> ModLoad: 712d0000 712fd000 C:\WINNT\system32\adsldp.dll
> ModLoad: 75da0000 75e5a000 C:\WINNT\system32\SXS.DLL
> ModLoad: 76f50000 76f63000 C:\WINNT\system32\SECUR32.DLL
> ModLoad: 71c00000 71c18000 C:\WINNT\system32\WS2_32.DLL
> ModLoad: 71bf0000 71bf8000 C:\WINNT\system32\WS2HELP.dll
> ModLoad: 71b20000 71b63000 C:\WINNT\system32\mswsock.dll
> ModLoad: 71ae0000 71ae8000 C:\WINNT\System32\wshtcpip.dll
> ModLoad: 76ed0000 76ef7000 C:\WINNT\system32\DNSAPI.dll
> ModLoad: 76f70000 76f77000 C:\WINNT\System32\winrnr.dll
> ModLoad: 76f80000 76f85000 C:\WINNT\system32\rasadhlp.dll
> ModLoad: 766f0000 76706000 C:\WINNT\system32\NTDSAPI.DLL
> ModLoad: 76c90000 76cb4000 C:\WINNT\system32\msv1_0.dll
> ModLoad: 71ca0000 71cf6000 C:\WINNT\system32\kerberos.dll
> ModLoad: 766e0000 766ec000 C:\WINNT\system32\cryptdll.dll
> ModLoad: 76190000 761a2000 C:\WINNT\system32\MSASN1.dll
> (fd4.15ac): Access violation - code c0000005 (first chance)
> First chance exceptions are reported before any exception handling.
> This exception may be expected and handled.
> eax=00000040 ebx=00000001 ecx=0012fb9c edx=00000001 esi=00000000
> edi=00000040
> eip=77bd4e36 esp=0012fa04 ebp=0012fa30 iopl=0 nv up ei pl nz
> na pe nc
> cs=001b ss=0023 ds=0023 es=0023 fs=0038 gs=0000
> efl=00010202
> *** ERROR: Symbol file could not be found. Defaulted to export
> symbols for C:\W
> INNT\system32\msvcrt.dll -
> msvcrt!wcslen+0x4:
> 77bd4e36 668b08 mov cx,[eax]
> ds:0023:00000040=????
> 0:000>
>
> ###############
>
> AK, thanks for going through all that trouble looking at the code. I
> will re-examine those issues that you've raised and do a follow up
> post after that.
>
> Thanks,


> H.
>
>
>
>
> "Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> wrote in message

news:<u3EY$LDEEH...@TK2MSFTNGP11.phx.gbl>...

H

unread,
Mar 23, 2004, 7:15:47 PM3/23/04
to
Sorry Ivan, i'm not too sure what you mean by "report output of the
'~*kb' command". Can you please brief me on this a bit?

Thanks,
H.
"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> wrote in message news:<u5KpkLIE...@tk2msftngp13.phx.gbl>...

Ivan Brugiolo [MSFT]

unread,
Mar 23, 2004, 8:01:10 PM3/23/04
to
at the debugger prompt ( the `0:000>' thing below) type
in that exact string `~*kb<enter>' (without the open backquote and trailing
quote,
and interpreting <enter> as common sense suggests).
That command will display a little bit more of what is going on.
Debugger commands are very concise, and the seem random strings at first
sight.

H

unread,
Mar 24, 2004, 7:49:31 PM3/24/04
to
Hi All,

I have finally solved the problem. It was a pointer pointing to an
array of data with one invalid data type which i overlooked.

Thank you very much for going great length to help me. I really
appreciated your patience and the willingness to help others. Please
keep up your good work.

Thanks,
H.
"Ivan Brugiolo [MSFT]" <ivan...@online.microsoft.com> wrote in message news:<ewBQttTE...@TK2MSFTNGP12.phx.gbl>...

0 new messages