CScriptDictionary static initializer crash

Started by
3 comments, last by Miss 5 years, 3 months ago

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?

Advertisement

I'll investigate and have it fixed a.s.a.p.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

This topic is closed to new replies.

Advertisement