I am currently making (trying to make, rather) a SAX (Simple Api for Xml) XML parser for mIRC. It basically reads an xml file into a &binvar and loops through it with $bfind to find tags, then parses the tag and sends signals (with /signal -n) when tags are opened, closed, for data, attributes, ect.
Its working great except on extremely large files (2k+ lines). My loop breaks most of the way through the loop and somehow the &binvar containing the XML is mysteriously unset.
myndzi (who wrote the code to reproduce the bug) and myself tracked it down to a limit in /signal -n calls, specifically when using the -n switch. Here is the code to reproduce the bug:
alias bvartest {
set %signalcalls 0
bset -t &t 1 Bug!
var %t = $ticks, %x = $ticks + 30000
while (%t < %x) {
.signal -n thingie
if (!$bvar(&t, 0)) break
}
echo -a ? bvar unset after %signalcalls signal calls
}
on *:signal:thingie:inc %signalcalls
The &binvar is always unset after 9991 calls. Im guessing this is due to some sort of limit (probably 10k) on the number of stacked /signals, however when using the -n switch they dont need to be stacked, so I am at a loss as to what exactly is causing this problem.
I have tried using /breading the file again when the bvar is unset with mixed results, sometimes it gives me an error and sometimes it doesnt. I have also tried using /fopen, and the bug seems to unset the contents of an opened file as well. I have also tried using a hash table to store the binary variable but it was painfully slow and because the binvar may be unset at any point during my loop, I am likely to lose a chunk of data by resetting the binvar (the data for the current tag likely being unset when the bug occurs).