DHI / DHI/mikecore-python

DFS file loading fails with Python 3.14 on Windows (error 2003) during test suite execution

クローズ
#41 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
5
フォーク
1
PR マージ指標
30日以内にマージされた PR はありません

説明

## Summary

mikecore fails to load DFS files with error 2003 (F_ERR_OPEN) when running test suites with Python 3.14 on Windows. Individual tests pass, but full suite execution experiences intermittent failures. Does not occur on Linux or with Python 3.13 on Windows.

## Reproduction

Discovered in modelskill test suite:
```bash
# Fails: Full suite on Windows + Python 3.14
pytest tests/ -v
# Exception: Could not load file ... (Error code 2003)

# Passes: Same test individually
pytest tests/test_pointcompare.py::test_score -v
```

## Test Results

| Platform | Python | Result |
|----------|--------|--------|
| Windows | 3.13 | ✅ Pass |
| Windows | 3.14 | ❌ Intermittent failures |
| Linux | 3.14 | ✅ Pass |

## Root Cause

Python 3.14 introduced ctypes thread safety changes for free-threaded builds. mikecore's singleton DLL loading pattern in `DfsDLL.py` (lines 42-61) lacks thread safety:

```python
class DfsDLL:
Wrapper = None # Global static, no locking

@staticmethod
def Init(libfilepath=None):
if DfsDLL.Wrapper is None: # Race condition
DfsDLL.Wrapper = ctypes.CDLL(...)
```

## Suggested Fix

Add thread-safe initialization with proper locking around singleton check and DLL loading.

## Workaround

Use Python 3.13 on Windows. See modelskill [commit ff699be8](https://github.com/DHI/modelskill/commit/ff699be818efae566e40159a7ef80264e6eec84b).

## Environment

- mikecore: 0.2.2
- Python: 3.14.2
- OS: Windows 11

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

DfsDLL.py の 42-61 行から始め、singleton DLL 読み込みパスと、テストを並行実行した場合の初期化動作を調査します。Windows 上で Python 3.14 を使って pytest tests/ -v を実行し、tests/test_pointcompare.py::test_score と比較します。完全なテストスイートで error 2003 が断続的に報告されなくなったら、作業完了とみなします。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
operating-systems
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。