473,326 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 = WaitForSingleObject (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(hReadyEvent);

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!KiFastSystemCallRet:
7c90eb94 c3 ret
0:011!analyze -v
************************************************** *****************************
*
*
* Exception Analysis
*
*
*
************************************************** *****************************
.....

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

EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 004e3fc8 (ListMode!AcqControl+0x000000a8)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 036ed958
Attempt to read from address 036ed958

DEFAULT_BUCKET_ID: INVALID_POINTER_READ

PROCESS_NAME: AcqRemServer.exe

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_<arch>_<arch>_<version>.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_TRANSFER: from 7c90e2dc to 004e3fc8

STACK_TEXT:
0482ffac 7c90e2dc 7c918e85 7c80b50b 00000000 ListMode!AcqControl+0xa8
[\pet\pet_common\source\ListMode/Listmode.cpp @ 1491]
0482ffb0 7c918e85 7c80b50b 00000000 00000000
ntdll!ZwRegisterThreadTerminatePort+0xc
0482ffb8 00000000 00000000 0121d3bc 00000000 ntdll!CsrNewThread+0xb
FAULTING_THREAD: 00000e60

PRIMARY_PROBLEM_CLASS: INVALID_POINTER_READ

BUGCHECK_STR: APPLICATION_FAULT_INVALID_POINTER_READ

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

SYMBOL_STACK_INDEX: 0

SYMBOL_NAME: ListMode!AcqControl+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!AcqControl_c0000005_INVALID_POINTER_R EAD

BUCKET_ID: APPLICATION_FAULT_INVALID_POINTER_READ_ListMode!Ac qControl+a8

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 4212
On Thu, 1 May 2008 11:14:00 -0700, socatoa
<so*****@discussions.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 = WaitForSingleObject (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(hReadyEvent);

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
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...
3
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...
4
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
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...
2
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...
1
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...
1
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...
0
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...
5
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.