Advertisement

a lot of strings causes assertion fail

Started by July 04, 2016 10:21 AM
3 comments, last by WitchLord 7 years ago

I run my script which use a lot of strings and after several runs my app crashing with this:


source/as_scriptengine.cpp:5893: int asCScriptEngine::AddConstantString(const char*, size_t): Assertion `stringConstants.GetLength() <= 65536' failed.

It seems like buffer overflow.

I don't need strings i pass after script will be executed but library still retain them. How i should clean up string cache to make it work?

Version of library is 2.30.2. I run script like this:


	std::string section = "usercode";

	asIScriptFunction *pfunc = nullptr;
	if(module->CompileFunction(section.c_str(),code.c_str(),0,0,&pfunc) < 0) {
		return 0;
	}

	asIScriptContext *context = requestContext(pfunc);
	context->Execute();
	context->Unprepare();
	pfunc->Release();

.

Example of my script


array<string> huge_array = {
    "1",
    "2",
    "3",
 
    ...
    // lots of strings here
    ...

    "9999",
    "10000"
};

foo(huge_array);

Hi TDM,

there is currently no way to clear the string cache other than releasing the engine and creating a new one from scratch.

I'll need to add some reference counting to the string cache so that the strings are freed when no longer used in any active script. This will on the other hand put a restriction on registered string type as the application must not keep a pointer to the string buffer, and instead must make a copy so that no dangling pointers occur when the engine releases its internal string buffer.

It's a complex task, and there is no solution that will fit everyone. I'll probably have to come up with a way to allow the application to implement its own strategy for the string cache through some kind of extension to the engine. I have already had thoughts along this line in the past. Now is probably a good time to increase the priority on this.

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

Advertisement

Ok, i get it. Thank you. Looking forward for future releases with some approach to fix this issue.

This restriction has now been removed in the latest WIP version. 

https://www.gamedev.net/forums/topic/693565-angelscript-changes-to-how-string-literals-are-handled/

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

This topic is closed to new replies.

Advertisement