-
Notifications
You must be signed in to change notification settings - Fork 184
Description
I have noticed a weird behaviour that occurs in long running scripts that have lots of memory churn. What happens is that a loop will work successfully for several 10's of thousands of iterations, and then it will error out that an operator is not appropriate. The line of code is one that was successfully run previously, but at this iteration it simply broke.
This is a tricky bug to isolate and reproduce because it is intermittent and non-deterministic.
Here is an example:
bsh.EvalError: Sourced file: xxxxxxxxxxx.bsh : Unary operation "++" inappropriate for object : at Line: 976 : in file: xxxxxxxxxxxxxx.bsh : ) {
The line in question in:
for (int k=0; k<inputs.length; k++) { // line 976This loop was repeating after 15 minutes of processing when the error occurred.
Here is another example:
bsh.EvalError: Sourced file: xxxxxxxxxx.bsh : Not an array or List type : at Line: 380 : in file: xxxxxxxxxxxxxx.bsh : [ i ]
The code for this line is:
Object yield(int year, double ba,double qmd, double cag, double cbg, double cinv, double vlog,
double[] oh, double[] df, double[] oc, double[] ce, double[] ww, double[] pn) {
for (int i=0; i<4; i++) {
oh[i] *= (1-0.11); // line 380
df[i] *= (1-0.07);
oc[i] *= (1-0.08);
ce[i] *= (1-0.11);
ww[i] *= (1-0.1);
pn[i] *= (1-0.07);
}There is only one call site for this scripted object and it calls the object ten's of thousands of times successfully, and then boom it fails.
When I look at what is going on with the debugger it turns out that the lookup of the k or oh variables is returning void, where in previous iterations the object was found correctly. I suspect that this has something to do with the ReferenceCache that uses weak references to BlockNameSpace objects and they are getting cleared too soon, but this is guessing. I am having a difficult time confirming this because of the nondeterminism and length of time it takes for the error to show up. By the time that the exception happens the 'cause' has already happened elsewhere.
Here is another one, I suppose that this is related:
bsh.EvalError: Sourced file: xxxxxxxx.bsh : Undefined argument: i : at Line: 739 : in file: xxxxxxxx.bsh : ( i )
The code for this line is
for (int i=0; i<yields.size(); i++) {
y = yields.get(i); // line 739All of these errors have shown up running the same script. Execution of long running scripts is like a box of chocolates: you never know what your gonna get. I am still digging in and trying to figure all of these out. I am posting this here in case anyone else has seem something like this and has any suggestions.
By the way, this is a script that successfully runs to completion using BeanShell 2.0b5.