This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Py_SAFE_DOWNCAST in FILE_TIME_to_time_t_nsec failing
Type: behavior Stage:
Components: None Versions: Python 2.7, Python 2.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, belopolsky, christian.heimes, kevinwatters, loewis, miss-islington, vstinner
Priority: normal Keywords: patch

Created on 2008-11-21 17:20 by kevinwatters, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
time_t_64.patch amaury.forgeotdarc, 2008-11-21 21:16 review
Pull Requests
URL Status Linked Edit
PR 25304 merged christian.heimes, 2021-04-09 13:21
PR 25307 open miss-islington, 2021-04-09 13:43
PR 25308 open miss-islington, 2021-04-09 13:43
Messages (8)
msg76193 - (view) Author: Kevin Watters (kevinwatters) Date: 2008-11-21 17:20
After releasing a Py_DEBUG build to some users who were experiencing 
problems, I noticed a pattern in some of the crash reports I got back:


The only way I can see _wassert being hit in FILE_TIME_to_time_t_nsec is 
in the Py_SAFE_DOWNCAST used to downcast an __int64 to int. 
Py_SAFE_DOWNCAST checks that there is equality between the casted and 
non-casted values with Py_DEBUG enabled--maybe in this function we 
should remove Py_SAFE_DOWNCAST?

I can't find a way to see the actual value for "in" before the assert is 
hit--I'm unfamiliar with picking through minidumps with WinDbg, which 
for some reason will show me the stack for these dumps when Visual 
Studio won't. But if I need to investigate more about them I can.
msg76201 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-21 20:29
You almost gave the answer in your question - the FILE_TIME is about to be 
converted to a time_t greater than 2**31.

in posixmodule.c::FILE_TIME_to_time_t_nsec(), a comment says:
/* XXX Win32 supports time stamps past 2038; we currently don't */
just before the assert()...

And indeed to reproduce the same crash it is enough to call os.stat() on a 
file with a creation date in 2050 for example.
msg76204 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-11-21 21:16
The attached patch corrects the problem: since VS2008 time_t is a 64bit 
integer; now os.stat() can return times after 2038 on Windows.

This prevents the crash, but the functionality is far from complete: 
os.utime() at least should accept 64bit times.
msg77506 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-12-10 08:47
IIUC, the patch relies on VS 2008. So it is not a candidate for 2.5.3.
msg128762 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-02-17 22:13
Oh, this issue was already fixed by r87666 to fix the duplicate issue #8278.
msg128763 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-02-17 22:13
> Oh, this issue was already fixed by r87666

... in py3k, and then merged into release31-maint (r87668) and release27-maint (r87669).
msg390620 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2021-04-09 13:43
New changeset 5151d642004c59cce58d669be85d9a5e987f51d3 by Christian Heimes in branch 'master':
bpo-4379: Skip TLS 1.0/1.1 tests under OpenSSL 3.0.0 (GH-25304)
msg390630 - (view) Author: miss-islington (miss-islington) Date: 2021-04-09 14:08
New changeset 4a5c101936900d11d723b59508464f73e4ab3a36 by Miss Islington (bot) in branch '3.9':
bpo-4379: Skip TLS 1.0/1.1 tests under OpenSSL 3.0.0 (GH-25304)
Date User Action Args
2022-04-11 14:56:41adminsetgithub: 48629
2021-04-09 14:08:39miss-islingtonsetmessages: + msg390630
2021-04-09 13:43:25miss-islingtonsetpull_requests: + pull_request24041
2021-04-09 13:43:22christian.heimessetmessages: + msg390620
2021-04-09 13:43:19miss-islingtonsetnosy: + miss-islington

pull_requests: + pull_request24040
2021-04-09 13:21:28christian.heimessetnosy: + christian.heimes

pull_requests: + pull_request24036
2011-02-17 22:13:56vstinnersetnosy: loewis, amaury.forgeotdarc, belopolsky, vstinner, kevinwatters
messages: + msg128763
2011-02-17 22:13:01vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg128762

resolution: fixed
2010-09-04 00:34:01pitrousetnosy: + belopolsky
2008-12-10 08:47:49loewissetnosy: + loewis
messages: + msg77506
versions: + Python 2.6, Python 2.7, - Python 2.5.3
2008-11-21 21:16:09amaury.forgeotdarcsetfiles: + time_t_64.patch
keywords: + patch
messages: + msg76204
2008-11-21 20:29:36amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg76201
2008-11-21 17:20:05kevinwatterscreate