473,851 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Has anyone seen anything like this

I have a class, that inherits from a class that inherits virtually from
another class. I have a breakdown occuring and it is not wrt the
virtually inherited class but one of the other MIed pure virtual
classes.

I get this in my call stack at the point of explosion:

Flo.exe!DDocume nt::Dispatch(DF Zone * ptr=0x0298d260) Line 94 + 0x32
bytes C++
Flo.exe!DDocume nt::Dispatch(DF Zone * __A0=0x0298d260 ) + 0x2f
bytes C++
Flo.exe!DDocume nt::ReadDocumen tItem(DType type=DT_ZONE,
DispatchAccepto r * & LinkParent=0x01 ce8c98, int & ctPipes=0x00000 000,
TangCount & DiskCount={...} , CDisk & disk={...}) Line 4534 + 0x17
bytes C++

Notice the second to the last call, the first call to something called
Dispatch. This function has no code to look at. It alters the object
pointed to by __A0 such that further up in the second call to Dispatch
things explode. It writes to pointers that should be null at this
point data that is apparently outside the program's memory space. This
function simply doesn't exist anywhere in code and has no line
information. Notice the name __A0, this is apparently an
implementation defined function and I have no idea why.

This only happens when a particular, and unrelated, class is inherited
virtually.

The compiler is MSVC++ 8 (VS2005). I will attempt to put up some code
that exhibits the problem, if I can, tomarro...for now I'm just
currious if anyone has seen this before and can identify what kind of
problem I am experiencing.

Oct 19 '06 #1
2 1386
Noah Roberts wrote:
I have a class, that inherits from a class that inherits virtually from
another class. I have a breakdown occuring and it is not wrt the
virtually inherited class but one of the other MIed pure virtual
classes.
Classes cannot crash, only objects can crash ;)
Where are your objects and what do they do? Without any piece
of sourcecode one can't help you anyway with your problem.

When you change something in a class declaration, you have to make
sure that all sourcecode that depends on that declaration, is
re-compiled.

Sometimes VC misses to compile all required files. This can be the
reason for strange errors. If in doubt, compile ALL sourcecode-
files of the project again ("make clean").

Best regards,
-Martin
Oct 20 '06 #2

Noah Roberts wrote:
I have a class, that inherits from a class that inherits virtually from
another class. I have a breakdown occuring and it is not wrt the
virtually inherited class but one of the other MIed pure virtual
classes.

I get this in my call stack at the point of explosion:

Flo.exe!DDocume nt::Dispatch(DF Zone * ptr=0x0298d260) Line 94 + 0x32
bytes C++
Flo.exe!DDocume nt::Dispatch(DF Zone * __A0=0x0298d260 ) + 0x2f
bytes C++
Flo.exe!DDocume nt::ReadDocumen tItem(DType type=DT_ZONE,
DispatchAccepto r * & LinkParent=0x01 ce8c98, int & ctPipes=0x00000 000,
TangCount & DiskCount={...} , CDisk & disk={...}) Line 4534 + 0x17
bytes C++

Notice the second to the last call, the first call to something called
Dispatch. This function has no code to look at. It alters the object
pointed to by __A0 such that further up in the second call to Dispatch
things explode. It writes to pointers that should be null at this
point data that is apparently outside the program's memory space. This
function simply doesn't exist anywhere in code and has no line
information. Notice the name __A0, this is apparently an
implementation defined function and I have no idea why.

This only happens when a particular, and unrelated, class is inherited
virtually.

The compiler is MSVC++ 8 (VS2005). I will attempt to put up some code
that exhibits the problem, if I can, tomarro...for now I'm just
currious if anyone has seen this before and can identify what kind of
problem I am experiencing.
I found my problem. I don't know why the Dispatch function has two
calls, one for an implementation defined version of the function but it
seems to only happen when I use the reoccuring template pattern
previous in the MI list to the DispatchAccepto r class (the interface
that defines those functions). I narrowed down the occurance of that
function to those cases but it wasn't causing a problem. No matter
what I did I couldn't recreate the problem...becau se I don't do silly
things like the following...it is so outside my methods now that I
didn't even think to try...

My problem was caused by C-Style casting. Someone had attempted
something akin to this in a header file:

#include "LinkObj.h"

class N;

class D
{
public:
LinkObj * Dispatch(N * n) { return n; }
};

Now, N is a LinkObj, everone reading the code knows this. However, the
compiler doesn't know it at this point so it demanded a cast. The
developer in question decided, "Ok, I'll cast it then," instead of
wondering why it needed one.

So they used a C-style cast:

LinkObj * Dispatch(N * n) { return (LinkObj *) n; }

BANG, reinterpret_cas t to 'unrelated' pointer resulting in undefined
behavior when the developer was obviously desiring a static_cast.

Later, I came along and started introducing MI to pull out
responsibilitie s in a refactor session. Went from undefined behavior
that worked to undefined behavior that did really rediqulous things,
like altering user defined pointers to point at virtual tables.

So kiddies, that just goes to show that you should never use C-Style
casts...ever. We have better casting options for a very good reason.
Undefined behavior can do ANYTHING...and can cost hours of trouble
tracking down.

As soon as I put the desired cast in there, just for a test, the
compiler puked. As soon as I moved the definitions from the header to
a cpp with knowledge of all types the sytem quit exploding and doing
wierd things. This cost my employer many dollars in hours I speant
trying to figure this out as well as a couple hours of a fellow
developer working with me to try and find the prob. C++ casts require
about 20 seconds, tops, to type and very little research on how to use
them and save many, many hours of work...use them.

I am currious why there is an extra, implementation defined, version of
the Dispatch function when I use the CRTP and inherit from that before
the one defining the dispatch function but as long as I don't introduce
UB it still works. The debugger won't step into it or anything past
that call so I'll avoid this situation when I can but it works 'as if'
so doesn't violate the std. Just a curriosity. Interestingly the
implentation defined vtbl goes away in that super class under these
conditions and is replaced by these funky function calls.

Oct 20 '06 #3

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

Similar topics

0
1211
by: Mart Rogers | last post by:
I have the following problem with an ASP.Net solution and would be grateful for any advice on solving it : I load an existing ASP.NET solution into Visual Studio (2002), then from Solution Explorer, right-click on one of the projects. In the pop-up menu, I selected Add, then Add Existing Item. After that the dialog box to select a file appeared (which is expected), followed by the error message :
1
2426
by: DickChristoph | last post by:
Hi We have a SQL 2000 (sp3) server with a database that I set up to have the MDF on D: and the LDF on E:. All was going along fine for several months and one day the server rebooted. The SQL log says something like "Service is shutting down due to server shutdown." When it came back up the LDF File was on D: (in the same folder as the MDF). The original LDF was gone from E:
0
310
by: numerous instabilities in deploying VB | last post by:
I have been working on a VB product It is working beautifuly on my XP dev box and my windows 2000 test machines in the lab. When I install at the customer site, I get all kinds of wacky problems that I CANT reproduce in the lab. 1) Some customer PC's can't use ANY functions related to Process = Process.GetProcessById(ProcessID) !!!! - I am resorting to using a 3rd party product to kill process. 2) Sometimes applications will just die...
13
2238
by: penguin732901 | last post by:
Checking back for discussions, there was a lot of talk about 2000 being slower than 97, but not so much lately. What is the latest opinion? Anyone care to set up a poll for how many NG members are still using 97? 2000? I am slightly tempted to upgrade by a new client whose data is in 2000, but of course, I can just port it all back through Excel...right? and I guess I have seen a couple of nice features...
8
1429
by: Wayne Gillespie | last post by:
I have an application in service (A97) which is a booking system for a modelling agency. When they add / edit a job I display a subform which lists all models, filtered according to criteria set by the user, from which they can select the model(s) they want to add to the job. The subform is bound to a temporary table (atblModelSelectTemp2 ) which contain several boolean fields which act as flags to indicate whether the model is already on...
8
7429
by: firewood | last post by:
I am developing a form-based website development system using PHP5, and I want to incorporate a secure, reliable, Wysiwyg textarea script in place of the standard, unformatable, text-only textarea one gets with a <textarea> tag. All I need are basic formatting tools - bold, italics, underline, lists, tables. I've looked into a few already with spotty results: SPAW - is buggy with PHP5. Textarearich - is awkward to configure, and I'm...
66
5428
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it occurs. After the program has read the file, it should offer a menu with three choices. the first is to list all the words along with the number of occurences. The second is to let you enter a word, with the program reporting how many times the...
5
2732
by: tony | last post by:
I'm using PHP 5 on Win-98 command line (ie no web server involved) I'm processing a large csv file and when I loop through it I can process around 275 records per second. However at around 6,000 records this suddenly drops off to around 40 records per second. This is a big problem as the "live" list is over 4 million records long. I'd break it up but this is to be a regular test so that would be messy
32
7518
by: Kevin Walzer | last post by:
I'm a Tcl/Tk developer who has been working, slowly, at learning Python, in part because Python has better support for certain kinds of applications that I want to develop than Tcl/Tk does. Naturally, I thought that I would use Tkinter as the GUI for these programs. However, in doing research into GUI development techniques, sample code, and showcase applications, what has struck me is how little sophisticated GUI development seems to be...
0
9748
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
11020
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...
1
10735
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
9506
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...
1
7907
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7073
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
5736
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
5934
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3180
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.