473,395 Members | 1,986 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,395 software developers and data experts.

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!DDocument::Dispatch(DFZone * ptr=0x0298d260) Line 94 + 0x32
bytes C++
Flo.exe!DDocument::Dispatch(DFZone * __A0=0x0298d260) + 0x2f
bytes C++
Flo.exe!DDocument::ReadDocumentItem(DType type=DT_ZONE,
DispatchAcceptor * & LinkParent=0x01ce8c98, int & ctPipes=0x00000000,
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 1346
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!DDocument::Dispatch(DFZone * ptr=0x0298d260) Line 94 + 0x32
bytes C++
Flo.exe!DDocument::Dispatch(DFZone * __A0=0x0298d260) + 0x2f
bytes C++
Flo.exe!DDocument::ReadDocumentItem(DType type=DT_ZONE,
DispatchAcceptor * & LinkParent=0x01ce8c98, int & ctPipes=0x00000000,
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 DispatchAcceptor 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...because 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_cast 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
responsibilities 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
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...
1
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...
0
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...
13
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...
8
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...
8
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...
66
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...
5
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...
32
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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.