Page 1 of 1

Crash when compiling script

Posted: Wed May 28, 2014 5:09 am
by NauticalMile
When I was zeroing in on the other bug I reported, I encountered another unexpected crash while editing a script. Regardless of what's in the RUBE scene, this script crashes the program when I paste it into the scratch-pad:

Code: Select all


body b = sb()[0];

void test(body b){
	//string parentName = b.parentName;
	string parentName = b.getCustomString('parentName');
	body parentBody = getBody(parentName);
	if(parentBody.valid)
		print('parent is valid');
}

void main(){

	test(b);
}

I'm running Windows 7. I understand that the script might not compile in the current format, but I don't expect it to crash RUBE.

Here is the error encountered before the program is terminated:
Image

Re: Crash when compiling script

Posted: Wed May 28, 2014 9:05 am
by iforce2d
Thanks for the report. Turns out it will crash with any attempt at static allocation, eg:

Code: Select all

body b = getBody("abc");
void main(){}
This presents quite a nuisance, since I guess every single script function needs a check to see if it is being called during compilation. Unfortunately with the current tally of 270 script functions this is not something I can fix overnight. In the meantime, don't do any static allocation. In the case of the script you are using, put the body b = sb()[0]; line inside the main() function so that the sb() does not actually get called until run-time.

This will not be a problem if your script does not have a main(), because in that case RUBE will wrap the entire script inside a main() for you.