Jump to content
  • Advertisement
Sign in to follow this  
Verg

Loki bug (which you can easily reproduce)

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

if you're bored [smile] Think Verg is still a dope? [smile] Here's the source which will cause a Loki library bug to happen, if you're bored and wanna try it... NOTE: You'll have to include the Loki files Singleton.cpp and SmallObj.cpp, as well as make the Loki header files available to your test project for it to build... The header file "test_3.h":
/************************************************************
* Loki library: potential bug #1219255                      *
*                                                           *
* Test case which causes apparent failure inside            *
* SmallObj.cpp vers 1.3                                     *
*                                                           *
* Files where bug was discovered were from:                 *
* (http://www.richsposato.com/SmallObject/SmallObject.zip)  *
*                                                           *
* Originals can be found at:                                *
* (http://sourceforge.net/projects/loki-lib)                *
*                                                           *
* by: Chad Lehman (icbiass_SPAMBLOCK_@hotmail.com)          *
* Date: June 12, 2005                                       *
*                                                           *
*************************************************************/

// The following test will cause the ASSERT on line 292
// of Rich's "SmallObj.cpp" to fail:

// assert( ( NULL == emptyChunk_ ) || ( emptyChunk_->HasAvailable( numBlocks_ ) ) );
//
// The emptyChunk_ pointer points to a chunk whose available
// blocks appear to be:
//
// emptyChunk->blocksAvailable_ == 254
//
// The following only appears to happen if the SmartPtr
// uses the RefCountedMTAdj<ClassLevelLockable>::RefCountedMT
// Ownership Policy.
//
// The assert comes after the second call to void testIt()
// inside int main()

#include <windows.h>	// so that _WINDOWS_ macro is
						// defined, which allows
						// ClassLevelLockable to be defined

#include <loki/SmartPtr.h>
#include <loki/Functor.h>

extern int main();
void testIt();

namespace testcase{

	using namespace Loki;

class holder{

public:

	class innerClass
	{

	public:

		innerClass(){}
		~innerClass(){}
	};

	typedef SmartPtr<innerClass, RefCountedMTAdj<ClassLevelLockable>::RefCountedMT >				inner_class_ptr_type;

	holder(){}
	virtual ~holder(){}

private:

	// assert fails! (line 292 SmallObj.cpp): 
	
	// When attempting to create this SmartPtr inside a
	// second object of type "holder"

	inner_class_ptr_type									_innerclass;
};


}



The .cpp file:
#include "test_3.h"

void testIt()
{
	testcase::holder h;
}

int main()
{
	testIt();
	testIt();     // uh oh! Trouble here!!

	system("PAUSE");
	return 0;
}



[smile] Yep, Verg is still a dope [lol]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!