Issue 10762: strftime('%f') segfault - Python tracker (original) (raw)

Issue10762

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: MajeedArni, amaury.forgeotdarc, dleonard0, kristjan.jonsson, loewis, mhammond, ned.deily, ocean-city, orsenthil, python-dev, r.david.murray, santoso.wijaya, terry.reedy
Priority: normal Keywords: patch

Created on 2010-12-23 09:57 by dleonard0, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue10762_py27.patch santoso.wijaya,2011-04-03 00:44 review
issue10762_py31.patch santoso.wijaya,2011-04-03 00:44 review
Messages (12)
msg124542 - (view) Author: David Leonard (dleonard0) Date: 2010-12-23 09:57
Installed http://www.python.org/ftp/python/2.7.1/python-2.7.1.amd64.msi on Windows 7, x64 into C:\Python27 C:\>\Python27\python.exe Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.strftime('%f') Dialog raises: "Python.exe has stopped working"
msg124554 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-23 14:58
Note that this is a regression relative to 2.6, where the same call returns '' (which is different from what it returns on linux, where the result would be '%f', or OSX, where the result would be 'f'). (Tests done on windows XP using pythons installed from the python.org installers.) My guess is that the difference between python 2.6 and python 2.7+ is issue 4804. I'm therefore adding the nosy list from that issue to this one. For the OP's benefit: my guess is that this is a bug in the Microsoft C runtime, but we probably need to provide a workaround for it in Python.
msg124595 - (view) Author: David Leonard (dleonard0) Date: 2010-12-24 12:29
Agree that the patches from issue 4804 and wrapping strftime() to catch the invalid_parameter call would fix this: windbg trace: 0:000> k Child-SP RetAddr Call Site 00000000`0021f328 000007fe`fdbb27cf ntdll!ZwTerminateProcess+0xa 00000000`0021f330 00000000`6ec24eec KERNELBASE!TerminateProcess+0x2f 00000000`0021f360 00000000`6ec24fc0 MSVCR90!invoke_watson+0x11c 00000000`0021f950 00000000`6ec11f5d MSVCR90!invalid_parameter+0x70 00000000`0021f990 00000000`6ec11fcd MSVCR90!Gettnames+0xebd 00000000`0021fa30 00000000`1e062e29 MSVCR90!strftime+0x15 00000000`0021fa70 00000000`1e0bff79 python27!PyTime_DoubleToTimet+0x5f9 00000000`0021fae0 00000000`1e10f084 python27!PyCFunction_Call+0x69 00000000`0021fb10 00000000`1e112834 python27!PyEval_GetGlobals+0x944 00000000`0021fb70 00000000`1e114039 python27!PyEval_EvalFrameEx+0x36a4 00000000`0021fc60 00000000`1e1140d9 python27!PyEval_EvalCodeEx+0x7e9 00000000`0021fd10 00000000`1e1400ca python27!PyEval_EvalCode+0x29 00000000`0021fd70 00000000`1e1417f6 python27!PyErr_Display+0x40a 00000000`0021fda0 00000000`1e14235e python27!PyRun_InteractiveOneFlags+0x1c6 00000000`0021fe10 00000000`1e1423d5 python27!PyRun_InteractiveLoopFlags+0xce 00000000`0021fe40 00000000`1e0443d9 python27!PyRun_AnyFileExFlags+0x45 00000000`0021fe70 00000000`1d00119e python27!Py_Main+0x8e9 00000000`0021ff30 00000000`777bf56d python+0x119e 00000000`0021ff60 00000000`779f3021 kernel32!BaseThreadInitThunk+0xd 00000000`0021ff90 00000000`00000000 ntdll!RtlUserThreadStart+0x21
msg124612 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-12-24 22:03
I verified problem with 3.2b1 on 32-bit winxp machine. IDLE restarts after pythonw crashes.
msg132823 - (view) Author: Santoso Wijaya (santoso.wijaya) * Date: 2011-04-03 00:15
There does not seem to be any mention of what an ANSI behavior should be upon encountering a non-supported format string. Hence, perhaps, the discrepancy among different platforms.
msg132824 - (view) Author: Santoso Wijaya (santoso.wijaya) * Date: 2011-04-03 00:35
I don't think this is a Windows "bug" per se, because the behavior is undefined in the standards. The burden is up to us to validate the format string inputted [w]strftime and currently, our code mistakenly clears "%f" as valid. I'm attaching a patch against 2.7 branch.
msg132825 - (view) Author: Santoso Wijaya (santoso.wijaya) * Date: 2011-04-03 00:44
Wrong filename. Attaching again: against 2.7 and 3.1 branches.
msg133109 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-06 06:16
New changeset 2ca1bc677a60 by Senthil Kumaran in branch '3.1': Issue #10762: Guard against invalid/non-supported format string '%f' on Windows. Patch Santoso Wijaya. http://hg.python.org/cpython/rev/2ca1bc677a60
msg133112 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-04-06 06:45
New changeset 1320f29bcf98 by Senthil Kumaran in branch '2.7': Issue #10762: Guard against invalid/non-supported format string '%f' on Windows. Patch Santoso Wijaya. http://hg.python.org/cpython/rev/1320f29bcf98
msg133113 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2011-04-06 06:48
Fixed it in relevant branches. I had to add condition around the test to verify that platform was win because this is unique to windows only. Thanks.
msg243631 - (view) Author: Majeed Arni (MajeedArni) Date: 2015-05-19 22:29
The problem still exists in 3.4 and 3.5 a4 Unhandled exception in thread started by
msg243636 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-05-20 00:03
Majeed, the fixes for this issue were released several years ago and the issue has been closed. Comments on it will likely be ignored. If you believe there is a problem in the current versions of Python 3 (3.4.3) or Python 2 (2.7.9), please open a new issue with appropriate supporting documentation of how to reproduce the problem (including platforms and versions used) and any resulting tracebacks.
History
Date User Action Args
2022-04-11 14:57:10 admin set github: 54971
2015-05-20 00:03:20 ned.deily set nosy: + ned.deilymessages: + versions: + Python 2.7, Python 3.2, - Python 3.4, Python 3.5
2015-05-19 22:29:37 MajeedArni set nosy: + MajeedArnimessages: + versions: + Python 3.4, Python 3.5, - Python 3.1, Python 2.7, Python 3.2, Python 3.3
2011-04-06 06:51:52 orsenthil set status: open -> closedassignee: orsenthilresolution: fixedstage: resolved
2011-04-06 06:48:09 orsenthil set nosy: + orsenthilmessages: +
2011-04-06 06:45:33 python-dev set messages: +
2011-04-06 06:16:35 python-dev set nosy: + python-devmessages: +
2011-04-03 00:44:52 santoso.wijaya set files: + issue10762_py31.patch
2011-04-03 00:44:44 santoso.wijaya set files: + issue10762_py27.patchmessages: +
2011-04-03 00:43:38 santoso.wijaya set files: - issue11703.patch
2011-04-03 00:35:43 santoso.wijaya set files: + issue11703.patchkeywords: + patchmessages: +
2011-04-03 00:15:31 santoso.wijaya set versions: + Python 3.3
2011-04-03 00:15:25 santoso.wijaya set messages: +
2011-04-01 08:19:35 santoso.wijaya set nosy: + santoso.wijaya
2011-04-01 06:43:18 amaury.forgeotdarc link issue11735 superseder
2011-02-02 18:59:54 belopolsky set nosy:loewis, mhammond, terry.reedy, amaury.forgeotdarc, kristjan.jonsson, ocean-city, dleonard0, r.david.murraycomponents: + Extension Modules, Windows, - Library (Lib)
2010-12-24 22:03:45 terry.reedy set nosy: + terry.reedymessages: +
2010-12-24 12:29:21 dleonard0 set nosy:loewis, mhammond, amaury.forgeotdarc, kristjan.jonsson, ocean-city, dleonard0, r.david.murraymessages: +
2010-12-23 14:58:23 r.david.murray set nosy: + r.david.murray, mhammond, kristjan.jonsson, amaury.forgeotdarc, loewis, ocean-citymessages: + versions: + Python 3.1, Python 3.2
2010-12-23 09:57:39 dleonard0 create