Stack overflow in regexp matcher