Crash when accessing custom ppty

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 accessing custom ppty

Post by NauticalMile »

iforce,

I've been playing around with v 1.6.0 and it looks great! :)

As promised, I've been trying to implement a couple of the things I mentioned in the Feature Requests threads. When doing some small tests, RUBE has crashed unexpectedly a couple of times. I managed to isolate the issue. It seems that when I repeatedly access a custom property via the . operator within a script that's called using a system hook, there is a memory conflict of some sort.

Anyway:
  • here is the rube scene I used
  • here is the rube script that highlights the issue
  • To reproduce the error with this scene, just associate the rubescript with the system hook and quickly and repeatedly translate body0
I don't think it's related to this issue, but I could be wrong.

As far as I can tell, the crash only occurs when the script is run from a system hook (In this case 'Bodies manipulated'), and only when the access occurs within a user defined function. But I have produced the crash several times under those conditions, so I do think this is the issue.

If I manually run the script repeatedly from the scratch pad (tap F5) I get the error:

Code: Select all

00:45:27: Skipping compile script because mutex lock failed.
Also, if I change the access method to:

Code: Select all

string parentName = b.getCustomString('parentName');
That also resolves the issue.

All in all this is a pretty obscure issue with an easy fix (just use the getCustom<type> methods inside functions within scripts that are called via system hooks), but I thought I would report it just the same.

EDIT: When the program crashes I first see the 'Running script' pop-up, followed by the windows message: 'R.U.B.E. editor has stopped working'. Then I'm forced to close it.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Crash when accessing custom ppty

Post by iforce2d »

Thanks for the report (again! ;)

As you suspected, this was indeed a problem with the . operator for custom properties. Internally the script engine maps the . operator to the getCustomString (or relevant equivalent) function. The trouble is, it was mapping to the version that takes a second parameter (a default value to return in the event that the property does not exist) and this screws up the function call. Seems like this is not an issue for primitive types (int, float etc) but for strings it causes trouble.

I'll try to get a fix out for this before too long, most likely bundled with the fix for the other error you just reported.

btw the warning about skipping script compile is not necessarily a problem. There are often multiple threads doing things, and to prevent them from treading on each other occasionally one may have to yield to another. In this case rather than lock and wait I opted to skip the process. In most cases, the process is the auto-compile of the script panel, but if you press F5 quickly enough you can cause the warning to happen because the previous script execution is still in progress.
Post Reply