473,783 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run-Time Check Failure #0 ... on a method call

1 New Member
Here is the error I get after calling a method (described below) :

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.

This is the code (simplified), the crash happend on line 49. I give some explainations after.
Expand|Select|Wrap|Line Numbers
  1.  
  2. //-------------------------------------------------------------
  3. class MyBaseClass 
  4. {
  5.  //...
  6. };
  7.  
  8. //-------------------------------------------------------------
  9. class MyInterface
  10. {
  11.   public:
  12.     virtual void OnTrigger(NxActor* actor1, NxActor* actor2) = 0;
  13. };
  14.  
  15. //-------------------------------------------------------------
  16. class MyClass : public MyBaseClass, public MyInterface
  17. {
  18. public: 
  19.  MyClass();   
  20.  void OnTrigger(NxActor* actor1, NxActor* actor2);   // called from a subsystem 
  21.                                                      // when an event is raised.
  22.  
  23. private:
  24.   NxActor* m_actor; 
  25. }
  26.  
  27. //-------------------------------------------------------------
  28. MyClass::MyClass()
  29. {
  30.   m_actor = CreateActor();      // create an actor for a particular sub system
  31.                                 // (PhysX)
  32.   m_actor.userData = this;      // hold the instance pointer to have a 1:1
  33.                                 // mapping between my instance and the actor 
  34.                                 // (userData is a void*)
  35. }
  36.  
  37. //-------------------------------------------------------------
  38. void MyClass::OnTrigger(Actor* actor1, Actor* actor2) 
  39. {
  40. }
  41.  
  42. //-------------------------------------------------------------
  43. //  The subsystem event callback 
  44. //-------------------------------------------------------------
  45. void OnSubSystemTrigger(NxActor* actor1, NxActor* actor2)
  46. {
  47.    if (actor1.userData)
  48.    {
  49.        MyInterface* obj = (MyInterface*) actor1.userData;  // cast
  50.        obj->OnTrigger(actor1, actor2);   // Call the method.Here is the crash
  51.    }
  52. }
- I checked if the value of userData didn't change between the constructor and the call. It is the same (eg : 0x0055c108).

- Just after the cast, obj is not valid "inside". When I use the VStudio watch on <MyInterface* obj> (line45) I get messy values :

Expand|Select|Wrap|Line Numbers
  1.    - MyInterface obj  0x0055c108
  2.      - MyClass
  3.        - MyBaseClass
  4.             __vfptr    0xfdfdfdfd    *
  5.        - MyInterface
  6.        - _actor    0x00000065 {userData=??? }    NxActor *

- And finally I get no error if iswitch the inheritance order from :
class MyClass : public MyBaseClass, public MyInterface
to :
class MyClass : public MyInterface, public MyBaseClass

Any idea ?

Thanks!
Dec 8 '07 #1
1 3877
weaknessforcats
9,208 Recognized Expert Moderator Expert
1) You are not calling your base class constructors in the MyClass constructor. That is, you need an intialization list where you call the base class constructors. The automatci calling of base class constructors has been disabled for multiple inheritance. This was done to prevent common base classes from having their constructors called multiple times.

2) Ditch that void*. A void* in C++ manes your calling a relci C function ir b) ytour design is screwed up.

3) You never cast in C++ as part of your normal coding style. If the C++ compiler cannot figure out your type, then you have real problems. If you need to be in charge of things, switch to C where nothing is done to help you.
Dec 8 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5178
by: James | last post by:
Hi, I would like to run a custom script on a linux box via a button on a php page (php webpage hosted on the same linux box). Is this possible? If so , can you give me a pointer in the right direction? thanks James
5
2236
by: hakim | last post by:
Hi, I need some information ? How I can run my project (Php) on CGI. Thanks.
0
1752
by: Pedro Werneck | last post by:
Hi, I don't know if I should ask this here or on an emacs group/list. If I choose wrong, please forgive me. I am trying to run pychecker on the current buffer on python-mode using the py-pychecker-run command, but it fails with the "Symbol's function definition is void: read-shell-command" error. I don't know elisp, but seems this is the point where the error occurs: ;; Pychecker (defun py-pychecker-run (command) "*Run pychecker...
3
4931
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run filename.py
8
3773
by: Jonathan Polley | last post by:
I have one account on a WindowsXP machine that refuses to run IDLE (or any other python script that uses Tk). Other people can login to that PC and IDLE runs just fine, so it is not an installation issue. When the person who has the problem logs into another PC the problem follows them. Any ideas as to what might me wrong? This is the traceback from IDLE: C:\Python20\Tools\idle>..\..\python.exe idle.py Traceback (most recent call...
0
7115
by: Kyle | last post by:
To any who chose to provide an answer, or even any suggestions to this problem, I thank you greatly in advance. +200 pts. for any valid solutions. I am currently in the process of converting a website from an existing web host to our servers. This website used the WScript.Shell command to execute a series of Java commands that would send an encrypted email. I ran these commands directly on the server and they execute properly,
12
2031
by: Mactash | last post by:
Folks, I am trying just to run a simple asp commands in the Internet Explorer. ( I have windows XP) When I run this asp lines on ASP Matrix web server it is ok. But, when I run this on IIS it acts like the asp engine is not working.
4
2688
by: SiuLoBow | last post by:
Hi, Is there anyway to detect the ActiveX control is able to run on the browser or not? After I installed the ActiveX control to my system, user sometimes switch the secruity setting to "not able to run ActiveX control". So, the ActiveX control just show on the broswer, but not able to run it. I want to find a way to detect it. And prompt the user a message telling
4
3217
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 my root directory, but I can run asp files from the root directory of my website and I can run htm files from the subdirectories. If I run localhost/mytest.asp
3
11302
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
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
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...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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
6735
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
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.