time() and friends have Y2038 problem on 64 Windows
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
I travelled 15 years into the future, and run the following code:
<?php
var_dump(time());
Resulted in this output:
int(-2081770632)
But I expected this output instead:
int(2213196664)
The problem is
https://github.com/php/php-src/blob/3d9a0a0c17c1660116c0699e6be734817d616292/win32/time.c#L46
Casting to long is appropriate since the declaration of struct timeval in WinSock2.h is:
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
However, long is a 32bit value on LLP64 architectures.
One may argue that time travel is not supportable, but maybe we should heed the POSIX 7 advise:
Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function.
gettimeofday() has been removed from POSIX 8 altogether.
PHP Version
any
Operating System
Windows
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
win32/time.c の、time() が tv_sec を取得してキャストするリンク先の行付近から始め、次にレポートで説明されている Windows LLP64 の制限と、関連する time APIs を確認します。64-bit Windows での動作を確認し、2038 年を超えても現在の 32-bit オーバーフローなしに正しい正のタイムスタンプを返すことを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100