Runtimer error R6025

BlitzMax Forums/BlitzMax Programming/Runtimer error R6025

TartanTangerine (was Indiepath)(Posted 2005) [#1]
I get this after my BMAX game has been running for about 5 mins. I have monitored the memory and there are no leaks.

This happens just after flushmem is called.

runtime error R6025
- pure virtual function call


This is what Microsoft say : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/R6025.asp

Is this a BlitzMax problem or something I have created?


TartanTangerine (was Indiepath)(Posted 2005) [#2]
I think I caused this problem with an external dll.


skidracer(Posted 2005) [#3]
That's what I was thinking too!


TartanTangerine (was Indiepath)(Posted 2005) [#4]
Yep it was my problem, my dll is running a process in a seperate thread and was filling up a buffer, when the buffer exploded so did BMAx.

Fixed now.


Damien Sturdy(Posted 2005) [#5]

This error is caused by calling a virtual function in an abstract base class through a pointer which is created by a cast to the type of the derived class, but is actually a pointer to the base class.



What the hell does all THAT mean!??? LOL!!!

Someone, untangle my brain!


Koriolis(Posted 2005) [#6]
If you are in the constructor of an abstract class, cast 'this' (equivalent of 'Self' in BlitzMax) to a concrete (not abstract) derived class and use that to call some pure virtual function (~= abstract method), kaboom. You end up trying to call a method that simply doesn't exist.
You shouldn't be able to easily face such a situation in BlitzMax, as there are only type safe casts in BlitzMax, and thus when attempting such a cast it will actually return Null.


marksibly(Posted 2005) [#7]
Actually, you *can* do this in Max!...
Type TBase

	Method New()
		Test()
	End Method
	
	Method Test() Abstract

End Type

Type TDerived Extends TBase

	Method Test()
		Print "Test"
	End Method

End Type

New TDerived

...must fix one day...


TartanTangerine (was Indiepath)(Posted 2005) [#8]
yeah my brain just fried with that one.


Koriolis(Posted 2005) [#9]
Yes, I actually had seen this one, forgot it. The result of a strange combination in BlitzMax I guess:
1) allowing virtual method calls from the constructor
2) while still considering that in TBase.New , Self is a TBase and only a TBase even if you actually instanciate a TDerived (meaning the virtual table is set in two stage, first to the table of TBase - set before TBase.New() -, then to the table of TDerived - set before TDerived.New().
Right?
The easiest way to fix this would be keep (1), and change (2):
setup the TDerived virtual table just once, even before TBase.New executes.
In fact I would ahve thought that was what you were doing in the first place, this is as far as I understand how java handles it. Which is the exact opposite of what C++ does.
--start of digression--
If I'm not mistaken the equivalent c++ program shouldn't ever compile, or at least link.
class TBase {
public:
	TBase() {
		Test();
	}
	
	virtual void Test() = 0;
};

class TDerived : public TBase {
public:
	void Test() {
		std::cout <<"Test" << std::endl;
	}
};

int main()
{
	TDerived * obj = new TDerived;
	return 0;
}
The previous code snippet indeed doesn't link with my compiler. But fooling it is easy, as the following code snippet compiles and exhibits a pure virtual call when run. Note that this code is not legal C++ code as per the C++ standard, so anything could happen. The program could well make your computer play tha traviata and you couldn't blame the compiler.
class TBase {
public:
	void Dummy() {
		Test();
	}
	TBase() {
		Dummy();
	}
	
	virtual void Test() = 0;
};

class TDerived : public TBase {
public:
	void Test() {
		std::cout <<"Test" << std::endl;
	}
};

int main()
{
	TDerived * obj = new TDerived;
	return 0;
}
--end of digression--


Curtastic(Posted 2005) [#10]
yes Koriolis I understand...
that bar in your sig gives a everyone a horizontal scrollbar on 1024x768, and dont tell me to go higher because my excellent laptop has no higher resolution.


Koriolis(Posted 2005) [#11]
Really? I *am* in 1024x768, and have no horizontal scrollbar. Can anyone else confirm/infirm? Probably due to the use of a different site theme.


kenshin(Posted 2005) [#12]
@Koriolis : Gives me a scrollbar at 1024*768 using the standard theme. Just confirming though, as I don't find it annoying 'cause I'm normally at 1600*1200.


Koriolis(Posted 2005) [#13]
Corrected.