The algorithm was using an invalid pointer returned by partition method.