Crash when compiling script

Report problems here (or use the built-in feedback dialog in the editor)
Post Reply
NauticalMile
Posts: 11
Joined: Wed Apr 09, 2014 1:56 am

Crash when compiling script

Post 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
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Crash when compiling script

Post 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.
Post Reply