473,732 Members | 2,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

0xC0000005 Access violation on a CreateEvent() call

Hi,

I have a DLL in VC6, when a specific function is called it will spawns a
few threads and then return. The threads stay running and inside one of these
threads an event is created using the win32 CreateEvent() call:

Code Snippet

static HANDLE hReadyEvent;

......
// inside a thread
hReadyEvent = CreateEvent (NULL, FALSE, FALSE, "DataReady" ) ;
if (hReadyEvent == NULL)
{
// Error condition
return ;
}
......
// The event is passed to a kernel mode driver, the threads waits for this
event to be set by the driver. which it does without a problem
retVal = WaitForSingleOb ject (hReadyEvent, INFINITE);
if (retVal != WAIT_OBJECT_0)
{
//error condition
return ;
}
// once the thread is finished with the work then closes the handle
if (hReadyEvent != NULL)
CloseHandle(hRe adyEvent);

Once the thread is done with the work, it will terminate itself and the
other threads. When the specific call from the DLL is called again, then the
threads will be spawned again, the event will be created again although the
handle is a static global handle.

This code has been working for many years as is but only when it is been
running in a multiprocessor system will fail sporadically. The createEvent()
call throws an access violation, but it does not do it every time, it
occurss very sporadically. Below is the dump file from this exception:

This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(710.e60): Access violation - code c0000005 (first/second chance not
available)
eax=03b50000 ebx=7c809c28 ecx=00001000 edx=7c90eb94 esi=0000019c edi=00000000
eip=7c90eb94 esp=0482e6f0 ebp=0482e754 iopl=0 nv up ei ng nz ac pe cy
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000297
ntdll!KiFastSys temCallRet:
7c90eb94 c3 ret
0:011!analyze -v
*************** *************** *************** *************** *************** ****
*
*
* Exception Analysis
*
*
*
*************** *************** *************** *************** *************** ****
.....

FAULTING_IP:
ListMode!AcqCon trol+a8 [\pet\pet_common \source\ListMod e/Listmode.cpp @ 1491]
004e3fc8 8b0a mov ecx,dword ptr [edx]

EXCEPTION_RECOR D: ffffffff -- (.exr 0xfffffffffffff fff)
ExceptionAddres s: 004e3fc8 (ListMode!AcqCo ntrol+0x000000a 8)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameter s: 2
Parameter[0]: 00000000
Parameter[1]: 036ed958
Attempt to read from address 036ed958

DEFAULT_BUCKET_ ID: INVALID_POINTER _READ

PROCESS_NAME: AcqRemServer.ex e

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at "0x%08lx" referenced
memory at "0x%08lx". The memory could not be "%s".

READ_ADDRESS: 036ed958

MANAGED_STACK: !dumpstack -EE
Failed to load data access DLL, 0x80004005
Verify that 1) you have a recent build of the debugger (6.2.14 or newer)
2) the file mscordacwks.dll that matches your version of
mscorwks.dll is
in the version directory
3) or, if you are debugging a dump file, verify that the file
mscordacwks_<ar ch>_<arch>_<ver sion>.dll is on your symbol
path.
4) you are debugging on the same architecture as the dump file.
For example, an IA64 dump file must be debugged on an IA64
machine.

You can also run the debugger command .cordll to control the debugger's
load of mscordacwks.dll . .cordll -ve -u -l will do a verbose reload.
If that succeeds, the SOS command should work on retry.

If you are debugging a minidump, you need to make sure that your executable
path is pointing to mscorwks.dll as well.

LAST_CONTROL_TR ANSFER: from 7c90e2dc to 004e3fc8

STACK_TEXT:
0482ffac 7c90e2dc 7c918e85 7c80b50b 00000000 ListMode!AcqCon trol+0xa8
[\pet\pet_common \source\ListMod e/Listmode.cpp @ 1491]
0482ffb0 7c918e85 7c80b50b 00000000 00000000
ntdll!ZwRegiste rThreadTerminat ePort+0xc
0482ffb8 00000000 00000000 0121d3bc 00000000 ntdll!CsrNewThr ead+0xb
FAULTING_THREAD : 00000e60

PRIMARY_PROBLEM _CLASS: INVALID_POINTER _READ

BUGCHECK_STR: APPLICATION_FAU LT_INVALID_POIN TER_READ

FOLLOWUP_IP:
ListMode!AcqCon trol+a8 [\pet\pet_common \source\ListMod e/Listmode.cpp @ 1491]
004e3fc8 8b0a mov ecx,dword ptr [edx]

SYMBOL_STACK_IN DEX: 0

SYMBOL_NAME: ListMode!AcqCon trol+a8

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: ListMode

IMAGE_NAME: ListMode.dll

DEBUG_FLR_IMAGE _TIMESTAMP: 47be9650

STACK_COMMAND: ~11s; .ecxr ; kb

FAILURE_BUCKET_ ID: ListMode.dll!Ac qControl_c00000 05_INVALID_POIN TER_READ

BUCKET_ID: APPLICATION_FAU LT_INVALID_POIN TER_READ_ListMo de!AcqControl+a 8

Followup: MachineOwner
---------

The line Listmode.cpp @ 1491 points to the createEvent() call. I just don't
understand how the CreateEvent() call can cause the access violation or what
could cause this to happened.

Please if somebody can help me, I will really appreciate it.

Thanks in advance,
Socatoa
Jun 27 '08 #1
2 4287
On Thu, 1 May 2008 11:14:00 -0700, socatoa
<so*****@discus sions.microsoft .comwrote:
>Hi,

I have a DLL in VC6, when a specific function is called it will spawns a
few threads and then return. The threads stay running and inside one of these
threads an event is created using the win32 CreateEvent() call:

Code Snippet

static HANDLE hReadyEvent;

.....
// inside a thread
hReadyEvent = CreateEvent (NULL, FALSE, FALSE, "DataReady" ) ;
if (hReadyEvent == NULL)
{
// Error condition
return ;
}
.....
// The event is passed to a kernel mode driver, the threads waits for this
event to be set by the driver. which it does without a problem
retVal = WaitForSingleOb ject (hReadyEvent, INFINITE);
if (retVal != WAIT_OBJECT_0)
{
//error condition
return ;
}
// once the thread is finished with the work then closes the handle
if (hReadyEvent != NULL)
CloseHandle(hRe adyEvent);

Once the thread is done with the work, it will terminate itself and the
other threads. When the specific call from the DLL is called again, then the
threads will be spawned again, the event will be created again although the
handle is a static global handle.

This code has been working for many years as is but only when it is been
running in a multiprocessor system will fail sporadically. The createEvent()
call throws an access violation, but it does not do it every time, it
occurss very sporadically.
Why does the handle need to be static? If the code you've shown above is
run by only one thread, why not use a local variable? On the other hand, if
multiple threads are waiting on the event, calling CloseHandle when there
are extant waits is undefined. I don't see how that could cause an access
violation the next time you call CreateEvent, but it wouldn't hurt to
check.

--
Doug Harrison
Visual C++ MVP
Jun 27 '08 #2
Hi Doug,

Thank you for your response. Only one thread is waiting for the event but
the handle is static because of the clean up mechanism that is implemented
which is not part of that thread but it is a global routine to clean up many
different things.
But when handle is closed from the clean up routine, the createEvent() is
always called before the event is used again. Is there something else I could
check?

Thanks,
Catalina

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
18023
by: Steven Reddie | last post by:
I understand that access violations aren't part of the standard C++ exception handling support. On Windows, a particular MSVC compiler option enables Microsoft's Structured Exception Handling (SEH) in C++ EH so that a catch (...) will catch an access violation. I don't know if other platforms support something similar. I'm wondering about how to best protect an application or library from poorly written user-defined callbacks. It...
3
6807
by: Kyle Teague | last post by:
I have a list of pointers to structs as a private member of a class. If I call begin() in the same function as I added the data then no access violation occurs. However, if I try to call begin() in a member function of the same class I get a memory access violation. For example: // this is fine, no error void CBase::FuncA( void ) { plugin_info_t *plugin_info = new plugin_info_t;
4
24176
by: batista | last post by:
Hi, I am getting the following exception First-chance exception in TestMansoor.exe: 0xC0000005: Access Violation When i run the following code 1 int main(void) 2 {
1
2591
by: Robert Ludewig | last post by:
I have sucessfully imported and compiled a complex MFC 6.0 project from vc++6.0 (MFC6.0) into vc++ 8.0 (MFC 8.0). It contains several subprojects (libs and dlls). In vc++ 6.0 those project linked MFC6.0 statically and after I imported it to vc++ 8.0 I set the linkage of MFC8.0 to "shared". However when I try to compile and link the project in vc++ 8.0 in release mode (debugmode works fine) I get an acess violation in afxcomctl32.inl. This...
2
9431
by: bhreddy | last post by:
Hi All, Can someone help me out how can I resolve the error "0xC0000005: Access violation reading location 0x513112f4"? Steps I followed... 1. I ran the application at DOS prompt 2. After some time my application got crashed and windows popped up a window asking for debug, send error report. 3. Clicking on Debug opens my workspace in .Net IDE.
1
2554
by: Umar Alam | last post by:
Hi, I am writing a windows socket program and it contains some threading in it as well. I connect the client to the server and they talk fine until i spawn a thread that takes care of the client while my server tried to accept another connection. while the functon that is being run by the thread is executing, the server is also getting ready to accept a new connection and it executes the "accept" command. Now at this point the...
1
12913
by: John Todd | last post by:
Hi, all. I've been working on a .NET project written in C# for the past three months. Yesterday, all of a sudden, I get The application failed to initialize properly (0xc0000005) error when i try to execute the .exe I built from my project. I'm sure I did not do any .NET framework install/uninstall/updates at all, neither did I delete any .dll files in any directory. Does anyone know what this error means? The only weird thing that I...
0
7127
by: vve | last post by:
I'm discovering a strange behaviour in an C# project using ZedGraph (https://sourceforge.net/projects/zedgraph/). After adding a signal to it, it seems that the clr goes mad for some reason. I don't get a nice exception in the debugger - instead I get a message in the output window "The program 'XXX.exe: Managed' has exited with code -1073741819 (0xc0000005)." and the application silently exits. I ran the compiled program with windbg...
5
5982
by: Tomas Vera | last post by:
Hello All, I have an app that is running throughout my company with one exception. Recently, one employee started throwing exception 0xC0000005 on startup. Specifically, it's crashing out during the load process. In testing I compiled a simple "Hello World" app in C#. Even that app fails to load.
0
8773
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9445
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9306
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9234
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6030
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4805
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.