Hang when fitting `SVC` to a specific dataset

### Describe the bug

I am trying to fit an [`SVC`](https://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html) to a specific dataset. The training process gets stuck, never finishing.

scikit-learn uses a fork of LIBSVM [version 3.10.0](https://github.com/scikit-learn/scikit-learn/blame/caaa1f52a0632294bf951a9283d015f7b5dd5dd5/sklearn/svm/src/libsvm/svm.h#L4) from [2011](https://github.com/cjlin1/libsvm/releases/tag/v310). The equivalent code using a newer version of LIBSVM succeeds, suggesting that there is an upstream bug fix that scikit-learn could merge in.

### Steps/Code to Reproduce

[libsvm_problematic_dataset.csv](https://github.com/user-attachments/files/17927924/libsvm_problematic_dataset.csv)

```python
import logging

from polars import read_csv
from sklearn.svm import SVC

_logger = logging.getLogger(__name__)


def main():
    dataset = read_csv(
        source='libsvm_problematic_dataset.csv'
    )

    x = dataset.select('feature').to_numpy()
    y = dataset['label'].to_numpy()

    _logger.info("Attempting to reproduce issue. If reproduced, the program will not exit.")

    SVC(
        C=100,
        kernel='poly',
        degree=4,
        gamma=0.9597420397825849,
        tol=0.01,
        cache_size=1000,
        class_weight={
            0: 1.04884106,
            1: 0.95550528
        },
        verbose=True
    ).fit(X=x, y=y)

    _logger.error("The issue was not reproduced.")


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    main()
```

### Expected Results

```
INFO:__main__:Attempting to reproduce issue. If reproduced, the program will not exit.
.................................................................................................
WARNING: using -h 0 may be faster
*..............................
WARNING: using -h 0 may be faster
*.............
WARNING: using -h 0 may be faster
*..................................................................
WARNING: using -h 0 may be faster
*..........................
WARNING: using -h 0 may be faster
*..........
WARNING: using -h 0 may be faster
*..............
WARNING: using -h 0 may be faster
*................
WARNING: using -h 0 may be faster
*................
WARNING: using -h 0 may be faster
*...........................
WARNING: using -h 0 may be faster
*..............
WARNING: using -h 0 may be faster
*.............
WARNING: using -h 0 may be faster
*.............
WARNING: using -h 0 may be faster
*.............................
WARNING: using -h 0 may be faster
*............................................
WARNING: using -h 0 may be faster
*.......
WARNING: using -h 0 may be faster
*......................
WARNING: using -h 0 may be faster
*.............
WARNING: using -h 0 may be faster
*.
WARNING: using -h 0 may be faster
*
optimization finished, #iter = 460766
obj = -245114.248664, rho = 1.000020
nSV = 2452, nBSV = 2450
Total nSV = 2452
ERROR:__main__:The issue was not reproduced.
```

This expected result was generated using LIBSVM [version 3.30.0](https://pypi.org/project/libsvm-official/3.30.0/) with the following code:
```python
import logging

from libsvm.svmutil import svm_train
from polars import read_csv

_logger = logging.getLogger(__name__)


def main():
    dataset = read_csv(
        source='libsvm_problematic_dataset.csv'
    )

    x = dataset.select('feature').to_numpy()
    y = dataset['label'].to_numpy()

    _logger.info("Attempting to reproduce issue. If reproduced, the program will not exit.")

    svm_train(
        y, x,
        [
            '-s', 0,
            '-t', 1,
            '-d', 4,
            '-g', 0.9597420397825849,
            '-c', 100,
            '-m', 1000,
            '-e', 0.01,
            '-w0', 1.04884106,
            '-w1', 0.95550528
        ]
    )

    _logger.error("The issue was not reproduced.")


if __name__ == '__main__':
    logging.basicConfig(level=logging.DEBUG)

    main()
```

### Actual Results

```
INFO:__main__:Attempting to reproduce issue. If reproduced, the program will not exit.
[LibSVM].....................................................
Warning: using -h 0 may be faster
*............
Warning: using -h 0 may be faster
*.....
Warning: using -h 0 may be faster
*.................
Warning: using -h 0 may be faster
*.....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
```

The program never exits.

### Versions

```shell
System:
    python: 3.11.10 | packaged by conda-forge | (main, Oct 16 2024, 01:26:25) [Clang 17.0.6 ]
executable: /opt/homebrew/Caskroom/miniforge/base/envs/libsvm-debugging/bin/python
   machine: macOS-14.7.1-arm64-arm-64bit

Python dependencies:
      sklearn: 1.5.2
          pip: 24.3.1
   setuptools: 75.6.0
        numpy: 2.1.3
        scipy: 1.14.1
       Cython: None
       pandas: None
   matplotlib: None
       joblib: 1.4.2
threadpoolctl: 3.5.0

Built with OpenMP: True

threadpoolctl info:
       user_api: blas
   internal_api: openblas
    num_threads: 10
         prefix: libopenblas
       filepath: /opt/homebrew/Caskroom/miniforge/base/envs/libsvm-debugging/lib/libopenblas.0.dylib
        version: 0.3.28
threading_layer: openmp
   architecture: VORTEX

       user_api: openmp
   internal_api: openmp
    num_threads: 10
         prefix: libomp
       filepath: /opt/homebrew/Caskroom/miniforge/base/envs/libsvm-debugging/lib/libomp.dylib
        version: None
```

COMMENT:
I was also able to reproduce the issue using the older scikit-learn version 0.17, so we can rule out any changes to the LIBSVM fork since Nov 5, 2015.

Labels: Bug, Needs Investigation