Using the latest version of KoLMafia (15.9 r12000) on both Java7 and Java6 (1.6.0_43-b01), it seems that if two matchers are executing in parallel, unpredictable results can occur.
The practical case where this is occurring is when a relay override script executes at the same time as a long running script. Specifically the scripts I'm seeing this issue with is between CHIT (replaces charpane.php) and BatBrain.
The random errors I see typically result in random string corruption where strings in one script override strings in another script. For example, BatBrain will sometimes attempt to process the familiar HTML strings due to this corruption. More unusual is that random zlib vars will get created or other variables also get randomly corrupted.
Example of odd zlib behavior:
The command (in CHIT): setvar("chit.walls.layout","modifiers,helpers,effects");
Resulted in:
> New ZLib string setting: -{15,17.5,20} => modifiers,helpers,effects
Here a BatBrain 'spread' appears to have wandered into CHIT's setting of variables.
Unfortunately, as it's rather random which strings get replaced and when this problem even occurs, it is difficult to replicate the string corruption and collect sufficient data.
However, I've been able to recreate some errors when running multiple matchers in parallel using some simple test scripts instead of the original scripts mentioned.
Pardon the crude code.
charpane.ash (Simulates a script using matchers):
test-race.ash (simulates a long running script using matchers like BatBrain):
Execute test-race.ash then reload the main relay browser page such that charpane.ash is refreshed (may take a few tries). This usually results in one of these unusual errors:
No match attempted or previous match failed (test-race.ash, line 20)
No match attempted or previous match failed (charpane.ash, line 17)
Group 3 requested, but pattern only has 3 groups (charpane.ash, line 17)
The practical case where this is occurring is when a relay override script executes at the same time as a long running script. Specifically the scripts I'm seeing this issue with is between CHIT (replaces charpane.php) and BatBrain.
The random errors I see typically result in random string corruption where strings in one script override strings in another script. For example, BatBrain will sometimes attempt to process the familiar HTML strings due to this corruption. More unusual is that random zlib vars will get created or other variables also get randomly corrupted.
Example of odd zlib behavior:
The command (in CHIT): setvar("chit.walls.layout","modifiers,helpers,effects");
Resulted in:
> New ZLib string setting: -{15,17.5,20} => modifiers,helpers,effects
Here a BatBrain 'spread' appears to have wandered into CHIT's setting of variables.
Unfortunately, as it's rather random which strings get replaced and when this problem even occurs, it is difficult to replicate the string corruption and collect sufficient data.
However, I've been able to recreate some errors when running multiple matchers in parallel using some simple test scripts instead of the original scripts mentioned.
Pardon the crude code.
charpane.ash (Simulates a script using matchers):
Code:
void main()
{
item i;
foreach i in $items[]
{
string itemName = to_string(i);
string itemNum = to_int(i);
string loopNum = 1;
string line = loopNum + ":" + itemNum + ":" + itemName + "<br>";
matcher extract;
extract = create_matcher("([^:]*):([^:]*):([^:]*)", line);
while(extract.find())
{
writeln("Number groups: " + group_count(extract) + "<br>");
writeln("[" + extract.group(1) + "] " + extract.group(2) + " - " + extract.group(3) + "<br>");
}
writeln(line) ;
}
}
test-race.ash (simulates a long running script using matchers like BatBrain):
Code:
void main()
{
item i;
foreach i in $items[]
{
foreach j in $items[]
{
string itemName = to_string(i);
string itemNum = to_int(i);
string loopNum = to_int(j);
string line = itemNum + ":" + loopNum + ":" + itemName + "\n";
matcher extract;
extract = create_matcher("([^:]*):([^:]*):([^:]*)", line);
while(extract.find())
{
print("Number groups: " + group_count(extract));
print("[" + extract.group(1) + "]" + extract.group(2) + "-" + extract.group(3));
}
print(line);
}
}
}
Execute test-race.ash then reload the main relay browser page such that charpane.ash is refreshed (may take a few tries). This usually results in one of these unusual errors:
No match attempted or previous match failed (test-race.ash, line 20)
No match attempted or previous match failed (charpane.ash, line 17)
Group 3 requested, but pattern only has 3 groups (charpane.ash, line 17)