473,396 Members | 2,029 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,396 software developers and data experts.

Run-Time Check Failure #0 ....

Error Message:

Run-Time Check Failure #0 - The value of ESP was not
properly saved across a function call. This is usually a
result of calling a function declared with one calling
convention with a function pointer declared with a
different calling convention.

There are several answers to this error, but my situation
is different. The place I get this error is at
WaitForSingleObject(). This is the builtin function, how
can I get around of this?

Thanks,

zhong
Nov 17 '05 #1
11 7953
Hello Zhong,

Thanks for posting in the group.

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible. If you have any more
concerns on it, please feel free to post here.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #2
"zhong" <zh*************@tek.com> wrote in message
news:04****************************@phx.gbl...
Error Message:

Run-Time Check Failure #0 - The value of ESP was not
properly saved across a function call. This is usually a
result of calling a function declared with one calling
convention with a function pointer declared with a
different calling convention.

There are several answers to this error, but my situation
is different. The place I get this error is at
WaitForSingleObject(). This is the builtin function, how
can I get around of this?
zhong


Hard to tell. But are you perhaps calling a function in a dll that uses
different calling conventions than MS conventions?

Tom.
Nov 17 '05 #3
Hi zhongsheng,

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Gary, and I
will be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.

From your description, I understand that you get a "Run-Time Check Failure
#0" when your program run steps into WaitForSingleObject() API call.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my experience, if your program don't have an explicit function
pointer that points to a different calling convention function, maybe it
would be the situation which Tom figured in the above post.

However, without further information about your program, we have no ways
to find out the problem exactly. Would please help me collect more
information about your program for further troubleshooting, such as what's
type of your project, do the program call some DLL's function, and what's
the context of the error code line....
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

Nov 17 '05 #4
Hi, Gary:

I did post the reply last week, but it seems there is
problem to display my message. Any way, here is where I
have the problem:

I have written the driver test application. I need use
the overlapped I/O to make asynchronous driver call.
After I called DeviceIoControl(), the stack is still
valid. However, when I step into WaitForSingleObject()
function call in the disassembly code, the stack
disappears. The default calling convention is __cdecl()
for the application, but I believe WaitForSingleObject()
is using __stdcall() calling convention. The problem is
WaitForSingleObject() is the builtin function, which is
out of my control. What I would like to know is how I can
get around.

I will try to post this message to the newsgroup.

Thanks for your help,
zhong
-----Original Message-----
Hi zhongsheng,

Thanks for using Microsoft MSDN Managed Newsgroup. My name is Gary, and Iwill be assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you get a "Run- Time Check Failure#0" when your program run steps into WaitForSingleObject () API call.Have I fully understood you? If there is anything I misunderstood, pleasefeel free to let me know.

Based on my experience, if your program don't have an explicit functionpointer that points to a different calling convention function, maybe itwould be the situation which Tom figured in the above post.
However, without further information about your program, we have no waysto find out the problem exactly. Would please help me collect moreinformation about your program for further troubleshooting, such as what'stype of your project, do the program call some DLL's function, and what'sthe context of the error code line....
Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.--------------------

.

Nov 17 '05 #5
"Zhong" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
I have written the driver test application. I need use
the overlapped I/O to make asynchronous driver call.
After I called DeviceIoControl(), the stack is still
valid. However, when I step into WaitForSingleObject()
function call in the disassembly code, the stack
disappears. The default calling convention is __cdecl()
for the application, but I believe WaitForSingleObject()
is using __stdcall() calling convention. The problem is
WaitForSingleObject() is the builtin function, which is
out of my control. What I would like to know is how I can
get around.


Pardon me for jumping into this conversation.

First, while it is always a possibility that there is a problem with
WaitForSingleObject() it is in my view an extraordinarily remote one because
the function is so central to asynchronous processing.

My guess is that there is stack corruption which just gets attributed to
WFSO().

One thing to check is that all of the data structures that are involved in
an async operation live until the operation completes. Sometimes developers
make mistakes by using an automatic (i.e. a stack-based) OVERLAPPED
structure in a function which returns before the I/O completes while the
wait is performed by the caller of that function. By the time the I/O
completes, the address passed to the read or write now points somewhere
else.

If that "somewhere else" is a stack frame, you will see the error that you
report.

Regards,
Will
Nov 17 '05 #6
Thanks, Bill:

I agree with you, but it seems it is not the case in my
function. Here is my code snipet. Please let me know if
you find anything weird. The error does not happy all the
time, but it does happen frequently. I saw this error
when I run the following function repeatedly in a loop
especially on Windows 2000.

Thanks,

zhong
// Omit the error check of course.
int DD_StartDma( ... )
{

DWORD StatusCode;
IOCTLDATA IoBuffer;
OVERLAPPED OverLapped, *pOverLapped;
HANDLE hEvent;
RETURN_CODE code = ApiSuccess;

hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
OverLapped.hEvent = hEvent;
OverLapped.Offset = 0;
OverLapped.OffsetHigh = 0;

memset(&(IoBuffer.u.DmaData.u.TxParams), 0, sizeof
(DMA_TRANSFER_ELEMENT));

// Initialize IoBuffer for transaction
IoBuffer.u.DmaData.u.TxParams.LocalToPciDma =
bLocal2Pci;
IoBuffer.u.DmaData.u.TxParams.TransferCount =
size;
IoBuffer.u.DmaData.u.TxParams.u.UserVa =
(UINT32)pUserVa; // Virtual address of buffer
IoBuffer.u.DmaData.u.TxParams.Offset =
nOffset;
IoBuffer.u.DmaData.u.TxParams.LocalAddr =
LocalAddress; // Local bus address
IoBuffer.u.DmaData.channel
= (DMA_CHANNEL)uChan;
IoBuffer.ReturnCode
= ApiSuccess;

// Macro for DeviceIoControl() call
IoMessage(
m_hDevice,
MDL_DMA_TRANSFER,
&(IoBuffer),
sizeof(IOCTLDATA),
&OverLapped
);

StatusCode = WaitForSingleObject(hEvent,
MAX_DMA_TIMEOUT );

switch (StatusCode)
{
case WAIT_OBJECT_0:
TRACE("Exit ... DD_StartDma succeeds ...\n");
code = ApiSuccess;
break;

case WAIT_TIMEOUT:
TRACE("Exit ... DD_StartDma timeout ...\n");
code = ApiPciTimeout;
break;

case WAIT_FAILED:
TRACE("Exit ... DD_StartDma failed ...\n");
code = ApiFailed;
break;

default:
TRACE("Exit ... DD_StartDma failed ...\n");
code = ApiFailed;
break;
}

CloseHandle(hEvent);
}

return code;
-----Original Message-----
"Zhong" <an*******@discussions.microsoft.com> wrote in messagenews:02****************************@phx.gbl...
I have written the driver test application. I need use
the overlapped I/O to make asynchronous driver call.
After I called DeviceIoControl(), the stack is still
valid. However, when I step into WaitForSingleObject()
function call in the disassembly code, the stack
disappears. The default calling convention is __cdecl()
for the application, but I believe WaitForSingleObject () is using __stdcall() calling convention. The problem is
WaitForSingleObject() is the builtin function, which is
out of my control. What I would like to know is how I can get around.
Pardon me for jumping into this conversation.

First, while it is always a possibility that there is a

problem withWaitForSingleObject() it is in my view an extraordinarily remote one becausethe function is so central to asynchronous processing.

My guess is that there is stack corruption which just gets attributed toWFSO().

One thing to check is that all of the data structures that are involved inan async operation live until the operation completes. Sometimes developersmake mistakes by using an automatic (i.e. a stack- based) OVERLAPPEDstructure in a function which returns before the I/O completes while thewait is performed by the caller of that function. By the time the I/Ocompletes, the address passed to the read or write now points somewhereelse.

If that "somewhere else" is a stack frame, you will see the error that youreport.

Regards,
Will
.

Nov 17 '05 #7
>>>The error does not happen all the time, but it does happen frequently.
I saw this error when I run the following function repeatedly in a loop
In the code snippet below (i.e. in DD_StartDma function), you are passing a
pointer to OVERLAPPED structure that is declared on the stack. If
DD_StartDma function returns before your asynchronous I/O completes, (e.g.
for the case where a WaitForSingleObject() call returned after your timeout
specified MAX_DMA_TIMEOUT), the pointer to OVERLAPPED structure you passed
for asynchronous I/O request you just issued (but not completed), is bogus
thereafter. When the asynchronous I/O completes later, it will corrupt the
stack when the OVERLAPPED structure is updated as it is pointer on the
stack of the thread that issued the /IO.

The lpOverlapped parameter *must* be valid for the duration of the
overlapped operation. i.e. until overlapped I/O completes. Allocate memory
for the overlapped structure on the heap.

If multiple I/O operations are simultaneously outstanding, each must
reference a separate OVERLAPPED structure, hEvent etc so that you have one
to one mapping for the corresponding asynchronous I/O.

Thanks,
Prab

--------------------Content-Class: urn:content-classes:message
From: "zhong" <zh*************@tek.com>
Sender: "zhong" <zh*************@tek.com>
References: <04****************************@phx.gbl> <HF*************@cpmsftngxa08.phx.gbl>
<02****************************@phx.gbl>
<uT**************@tk2msftngp13.phx.gbl>Subject: Re: Run-Time Check Failure #0 ....
Date: Mon, 19 Jan 2004 13:18:34 -0800
Lines: 141
Message-ID: <03****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcPe0cwOWojXDZmQQfysApNVuIKQyw==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.languages.vc
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.vc:32120
NNTP-Posting-Host: tk2msftngxa09.phx.gbl 10.40.1.161
X-Tomcat-NG: microsoft.public.dotnet.languages.vc

Thanks, Bill:

I agree with you, but it seems it is not the case in my
function. Here is my code snipet. Please let me know if
you find anything weird. The error does not happy all the
time, but it does happen frequently. I saw this error
when I run the following function repeatedly in a loop
especially on Windows 2000.

Thanks,

zhong
// Omit the error check of course.
int DD_StartDma( ... )
{

DWORD StatusCode;
IOCTLDATA IoBuffer;
OVERLAPPED OverLapped, *pOverLapped;
HANDLE hEvent;
RETURN_CODE code = ApiSuccess;

hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
OverLapped.hEvent = hEvent;
OverLapped.Offset = 0;
OverLapped.OffsetHigh = 0;

memset(&(IoBuffer.u.DmaData.u.TxParams), 0, sizeof
(DMA_TRANSFER_ELEMENT));

// Initialize IoBuffer for transaction
IoBuffer.u.DmaData.u.TxParams.LocalToPciDma =
bLocal2Pci;
IoBuffer.u.DmaData.u.TxParams.TransferCount =
size;
IoBuffer.u.DmaData.u.TxParams.u.UserVa =
(UINT32)pUserVa; // Virtual address of buffer
IoBuffer.u.DmaData.u.TxParams.Offset =
nOffset;
IoBuffer.u.DmaData.u.TxParams.LocalAddr =
LocalAddress; // Local bus address
IoBuffer.u.DmaData.channel
= (DMA_CHANNEL)uChan;
IoBuffer.ReturnCode
= ApiSuccess;

// Macro for DeviceIoControl() call
IoMessage(
m_hDevice,
MDL_DMA_TRANSFER,
&(IoBuffer),
sizeof(IOCTLDATA),
&OverLapped
);

StatusCode = WaitForSingleObject(hEvent,
MAX_DMA_TIMEOUT );

switch (StatusCode)
{
case WAIT_OBJECT_0:
TRACE("Exit ... DD_StartDma succeeds ...\n");
code = ApiSuccess;
break;

case WAIT_TIMEOUT:
TRACE("Exit ... DD_StartDma timeout ...\n");
code = ApiPciTimeout;
break;

case WAIT_FAILED:
TRACE("Exit ... DD_StartDma failed ...\n");
code = ApiFailed;
break;

default:
TRACE("Exit ... DD_StartDma failed ...\n");
code = ApiFailed;
break;
}

CloseHandle(hEvent);
}

return code;
-----Original Message-----
"Zhong" <an*******@discussions.microsoft.com> wrote in
message
news:02****************************@phx.gbl. ..
> I have written the driver test application. I need use
> the overlapped I/O to make asynchronous driver call.
> After I called DeviceIoControl(), the stack is still
> valid. However, when I step into WaitForSingleObject()
> function call in the disassembly code, the stack
> disappears. The default calling convention is __cdecl()
> for the application, but I believe WaitForSingleObject
()
> is using __stdcall() calling convention. The problem is
> WaitForSingleObject() is the builtin function, which is
> out of my control. What I would like to know is how I
can
> get around.

Pardon me for jumping into this conversation.

First, while it is always a possibility that there is a
problem with
WaitForSingleObject() it is in my view an
extraordinarily remote one because
the function is so central to asynchronous processing.

My guess is that there is stack corruption which just
gets attributed to
WFSO().

One thing to check is that all of the data structures
that are involved in
an async operation live until the operation completes.
Sometimes developers
make mistakes by using an automatic (i.e. a stack-
based) OVERLAPPED
structure in a function which returns before the I/O
completes while the
wait is performed by the caller of that function. By the
time the I/O
completes, the address passed to the read or write now
points somewhere
else.

If that "somewhere else" is a stack frame, you will see
the error that you
report.

Regards,
Will
.


Nov 17 '05 #8
Hello Zhong,

How are things going? I would appreciate it if you could post here to let
us know the status of the issue. If you have any questions or concerns,
please don't hesitate to let us know. We look forward to hearing from you,
and we am happy to be of assistance.

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 17 '05 #9
Thanks, Prab. You are right. After I make the change, it works now.

zhong
Nov 17 '05 #10

Well, im having the same problem when calling ID3DXSPRITE::Draw() thi
may be the wrong place to talk about a direct x function... but..
since i dont really know much assembly... i dont really know what
going on, im not calling a function pointer (i dont think....)

heres the code

bool SPRITE::Render()
{
if (FAILED(SPRITE::Sprite->Draw(SPRITE::pTex, NULL, NULL, NULL, NULL
&(SPRITE::Position), 0xFFFFFFFF)))
return FALSE;
return TRUE;
}

where SPRITE is my encapsulation class, Sprite is an LPD3DXSPRIT
(ID3DXSPRITE *) and position is a D3DXVECTOR2 (2 floats), the erro
seemed to only crop up after i defined the same function for a derive
class (its virtual)

yeha if anyone knows what im rambling about and how to remedy it.
thatd be great... thanx al

Adema
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message284817.htm

Nov 17 '05 #11
>Well, im having the same problem when calling ID3DXSPRITE::Draw() this
may be the wrong place to talk about a direct x function... but...
since i dont really know much assembly... i dont really know whats
going on, im not calling a function pointer (i dont think....)
...
...the error
seemed to only crop up after i defined the same function for a derived
class (its virtual)


A virtual function is called via a pointer, so, its a similar
situation. However, I've no experience with ID3DXSPRITE::Draw and I
can't imagine how it could easily be misused providing you've used the
definitions in the standard header files.

Since the problem only occurred when you added the derived class, I'd
certainly suspect something that's not right in that area. Sorry I
can't tell you anything definite.

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #12

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

Similar topics

4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
4
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C#...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
3
by: emman_54 | last post by:
Hi every one, I am trying to run a batch file using my asp.net application. I am using the Process class to run the batch file. When I run my web application, In the task manager, i could see...
19
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.