Random hangs on M1 in Apple Accelerate when performing sparse Cholesky factorization

Hello, I'm trying to use Accelerate's sparse Cholesky solver but met an issue on M1. Is anyone aware of this issue or similar ones?

The sparse factorization class _SparseNumericFactorSymmetric in Apple Accelerate will hang randomly for some large symmetric positive definite matrices with a specific sparsity pattern when created for Cholesky factorization.

This issue happens in probability about 1/1000. It can be reproduced through following steps

  1. Read and load the attached sparse matrix (in MatrixMarket format).
  2. In a for-loop, repeatedly factorize the same matrix through _SparseNumericFactorSymmetric for 1000~2000 times.

Matrix: https://www.dropbox.com/s/2pyl0cpmgy1qdrh/mat.mtx.zip?dl=0

The following code calls Apple Accelerate through a wrapper from Eigen 3.4.9 (https://eigen.tuxfamily.org/dox/group__AccelerateSupport__Module.html):

#include <unsupported/Eigen/SparseExtra>
#include <Eigen/AccelerateSupport>
#include <iostream>

int main() {
    Eigen::SparseMatrix<double> A;
    Eigen::loadMarket(A, "mat.mtx");
    
    for (int i = 0; i < 2000; ++i) {
        Eigen::AccelerateLLT<Eigen::SparseMatrix<double>> solver;
        solver.compute(A);
        std::cout << i << std::endl;
    }
    
    return 0;
}

The factorizations should perform smoothly for the times specified in the for-loop. But the app will hang and stop being responsive infinitely after performing the factorization for hundreds of times (sometimes ~500+ loops, or sometimes ~900+ loops).

I'm using a Xcode Version 13.1 (13A1030d) on MacOS Monterey 12.5.1 (21G83), with Apple M1 Max. It seems this issue is related to multithreading in VecLib since it only happens when we leave the environment variable unset (i.e., VECLIB_MAXIMUM_THREADS > 1). Setting VECLIB_MAXIMUM_THREADS = 1 will eliminate the issue at the cost of losing performance. And this issue only happens on M1 Macs, not on Intel-based ones.