Jump to content
  • Advertisement
Sign in to follow this  

a lot of strings causes assertion fail

This topic is 388 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

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);



Example of my script

array<string> huge_array = {
    // lots of strings here


Edited by deTDM

Share this post

Link to post
Share on other sites



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.

Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites
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!