Okay, I cooked something up and tested it. Here's the script (adjust FILE var at top to point at a sane place):
- Code: Select all
# Stress test
var FILE = "/Users/philosopher/Dropbox/Mihihehe/crash_index.log";
var namespace = nil;
var run1 = func {
if (namespace == nil) namespace = {};
var testfn = compile(testfn_str);
call(testfn, nil, nil, namespace);
};
var run = func(times=100008) {
var f = io.open(FILE, 'w');
io.seek(f, 0, io.SEEK_SET);
for (var i=0; i<times; i+=1) {
io.write(f, i~"");
io.seek(f, 0, io.SEEK_SET);
run1();
}
io.write(f, "");
io.close(f);
};
var testfn_str = '
var j = [];
for (var i=0; i<10; i+=1)
append(j, [[[]],[[]],[[]],[[]]]);
setsize(j, 0);
';
var _t = systime();
run(); namespace = nil;
printf("memory succeeded (took %03f seconds)", systime()-_t);
var testfn_str = '
var y = props.globals.getNode("sim");
y.getValue("author");
';
var _t = systime();
run(); namespace = nil;
printf("getNode succeeded (took %03f seconds)", systime()-_t);
var old_cmdarg = globals.cmdarg;
var _cmdarg = props.Node.new();
globals.cmdarg = func _cmdarg;
var testfn_str = '
cmdarg().setValue("setting", rand());
controls.throttleAxis();
';
var _t = systime();
run(); namespace = nil;
printf("throttleAxis succeeded (took %03f seconds)", systime()-_t);
globals.cmdarg = old_cmdarg;
globals.__test_tmp = {};
var testfn_str = '
var g = props.Node.new().getNode("binding", 1);
g.setValues({
"command": "nasal",
"module": "__test_tmp",
"script": "controls.mixtureAxis()",
"setting": rand(),
});
props.runBinding(g);
';
var _t = systime();
run(); namespace = nil;
printf("binding running succeeded (took %03f seconds)", systime()-_t);
delete(globals, "__test_tmp");
And run with
--prop:/nasal/test/file=/..../stress_test.nas (again, adjust to work).
Not all the time, but some of the time it crashes on the last part - running nasal-command bindings. For example, my $FILE (which holds the index of the test, aka how many times it has succeeded so far) reads 94586 after the last run that crashed FG. Haven't gotten a backtrace, but I assume it would be similar.
Given these (preliminary) results, it must be something with the fgcommand or FGNasalSys:handleCommand()... Because I'm compiling code on the fly in the previous test snippets, and essentially doing the same things as the C++, except maybe in a safer fashion (hehe, that's a little ironic). I wonder, if I don't call a function, it shouldn't reach the setupArgs(), so it might not crash? Will test some other permutations then.
edit: wiki page now:
http://wiki.flightgear.org/User:Philoso ... nd_crashes edit2: Now it made it to a valiant 119428 times in the binding area, after 300008 in each of the others. So I'm pretty sure it's only the binding code, not the equivalent in Nasal that can cause this
.
edit3: it keeps crashing on index 119428 on my system... quite suspicious