Jump to content
  • Advertisement
Sign in to follow this  
Miss

CScriptDictionary static initializer crash

Recommended Posts

I haven't been able to fully figure out what's going on yet, but this seems to crash on Windows with a "bad_alloc" exception, when put outside of a function:

dictionary g_thing = {
	{ "key", "value" }
};

I reverted to an earlier version of CScriptDictionary and there it doesn't happen. Seems like the difference is some GC enum things?

Share this post


Link to post
Share on other sites
Advertisement

I haven't been able to reproduce this problem.

Do you have any customization of the library or add-ons in your code that I need to know of?

Did you make sure you have all the latest files from the SDK? (you did have the problem of not updating all the files before too 😉)

Here's the test case I wrote to attempt to reproduce the problem. Does this reproduce it for you?

	{
		engine = asCreateScriptEngine();
		engine->SetMessageCallback(asMETHOD(CBufferedOutStream, Callback), &bout, asCALL_THISCALL);
		bout.buffer = "";

		RegisterStdString(engine); // Register string type as ref type
		RegisterScriptArray(engine, false);
		RegisterScriptDictionary(engine);

		mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
		mod->AddScriptSection("test",
			"dictionary g_thing = { \n"
			"	{ 'key', 'value' } \n"
			"}; \n");
		r = mod->Build();
		if (r < 0)
			TEST_FAILED;

		if (bout.buffer != "")
		{
			PRINTF("%s", bout.buffer.c_str());
			TEST_FAILED;
		}

		engine->ShutDownAndRelease();
	}

Note, I have other test cases already with global dictionaries being initialized like this, so it really shouldn't be something that slipped through the regression testing done with each check-in.

Share this post


Link to post
Share on other sites

Ah I see, you were totally right. So I did make a few changes that were required in my case that I unknowingly overwrote when copying the new changes. Consider this report invalid. :)

In the header file for the dictionary I changed the typedef for "dictKey_t" and also "dictMap_t" in order to use a custom string type that doesn't provide a hashing function yet.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!