I'm not sure what conditions lead to the i and j indices walking off the ends, but they do sometimes, seemingly randomly but probably not really.
I altered my local copy at line 102 in the sort fn from:
if lo<hi{local p is pt(A, lo, hi). qs(A, lo, p). qs(A, p + 1, hi).}}
to:
if (lo>0 AND hi<A:LENGTH-1) AND lo<hi{local p is pt(A, lo, hi). qs(A, lo, p). qs(A, p + 1, hi).}}
and the issue went away for me. But there is probably a more robust solution