time() and friends have Y2038 problem on 64 Windows
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.1k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in win32/time.c bei der verlinkten Zeile, in der time() tv_sec abruft und castet, und prüfe dann die im Bericht beschriebene Windows-LLP64-Einschränkung sowie die zugehörigen time APIs. Bestätige das Verhalten unter 64-Bit-Windows und definiere den Abschluss als das Zurückgeben eines korrekten positiven Zeitstempels nach 2038 ohne den aktuellen 32-Bit-Überlauf.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, php
- Bereich
- operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100