Segfault from `zoneinfo` with custom DateTime class
オープン
まだ誰も着手していません。
extension-modules
type-crash
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Crash report
What happened?
Here's a minimal reproducer
import zoneinfo
from datetime import date
class MyDateTime:
def __init__(
self,
year: int,
month: int,
day: int,
hour: int = 0,
minute: int = 0,
second: int = 0,
) -> None:
self.ordinal = date(year, month, day).toordinal()
self.hour = hour
self.minute = minute
self.second = second
def toordinal(self) -> int:
return self.ordinal
def whoopsie():
tz_berlin = zoneinfo.ZoneInfo("Europe/Berlin")
dt = MyDateTime(1995, 9, 2, 14, 34, 56)
print(tz_berlin.utcoffset(dt), flush=True)
If I run whoopsie, I get one of the following outcomes:
- It prints
02:00:00 - It prints
01:00:00 - It prints
00:53:28 - It segfaults
<project dir>/venv313/bin/python -X dev <project dir>/segfault.py
Fatal Python error: Segmentation fault
Current thread 0x00007fd62be47b80 (most recent call first):
File "<project dir>/segfault.py", line 27 in whoopsie
File "<project dir>/segfault.py", line 34 in <module>
I've tried running the test in a loop and it seems to always spit out the same result within a single run. So I assume some global state, memory layout, or or such is involved.
CPython versions tested on:
3.9, 3.13
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.13.0 (main, Oct 10 2024, 13:32:18) [GCC 11.4.0]
Linked PRs
- gh-125345
- gh-125824
- gh-139132
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
issue 本文の最小の reproducer から始め、記載されている CPython バージョンで実行して、クラッシュとオフセットの不整合を確認します。次に、リンクされている PR gh-125345、gh-125824、gh-139132 を読みます。reproducer が segfault せず、安定した正しい結果を生成するようになれば、作業は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100