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.

classification
Title: Python 2.4.1 crashes when importing the attached script
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: loewis Nosy List: complex, doerwalter, loewis, tim.peters
Priority: high Keywords:

Created on 2005-08-04 07:18 by complex, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python_2.4.1_crash.py complex, 2005-08-04 07:18 Script to reproduce the bug
Messages (5)
msg25978 - (view) Author: Viktor Ferenczi (complex) Date: 2005-08-04 07:18
OS: WinXP Prog. ENG SP1
Python: 2.4.1 MSI installer downloaded from python.org

Python crashes or rarely raises MemoryError or SyntaxError when trying to import/execute the script attached. The behaviour changes when some lines are modified, but mostly crashes the python process with a memory access violation. The python process used 4.2Mbytes of system memory when crashed. There were more than 500Mbytes free.

Register dump:

EAX = 00A8CC61
EBX = 0000000A
ECX = 00000000
EDX = 00000000
ESI = 00A10DA0
EDI = 00000022
EIP = 1E0A7F10
ESP = 0021FD98
EBP = 00000222
EFlags = 00000293

Other registers are irrelevant. The bug occured at the last line of the following instruction sequence because ECX was zero:

1E0A7EB2 66 C7 02 0A 00       mov         word ptr [edx],0Ah
1E0A7EB7 8B 46 08             mov         eax,dword ptr [esi+8]
1E0A7EBA 6A 00                push        0
1E0A7EBC 50                   push        eax
1E0A7EBD FF 15 B4 31 0C 1E    call        dword ptr ds:[1E0C31B4h]
1E0A7EC3 89 46 08             mov         dword ptr [esi+8],eax
1E0A7EC6 8A 48 FF             mov         cl,byte ptr [eax-1]
1E0A7EC9 83 C4 08             add         esp,8
1E0A7ECC 80 F9 0A             cmp         cl,0Ah
1E0A7ECF 0F 85 72 FF FF FF    jne         1E0A7E47
1E0A7ED5 BB 0A 00 00 00       mov         ebx,0Ah
1E0A7EDA 8B 0E                mov         ecx,dword ptr [esi]
1E0A7EDC 8B 54 24 0C          mov         edx,dword ptr [esp+0Ch]
1E0A7EE0 8D 04 11             lea         eax,[ecx+edx]
1E0A7EE3 89 46 04             mov         dword ptr [esi+4],eax
1E0A7EE6 8B 46 08             mov         eax,dword ptr [esi+8]
1E0A7EE9 83 E8 02             sub         eax,2
1E0A7EEC 3B C1                cmp         eax,ecx
1E0A7EEE 72 0F                jb          1E0A7EFF
1E0A7EF0 80 38 0D             cmp         byte ptr [eax],0Dh
1E0A7EF3 75 0A                jne         1E0A7EFF
1E0A7EF5 C6 00 0A             mov         byte ptr [eax],0Ah
1E0A7EF8 40                   inc         eax
1E0A7EF9 C6 00 00             mov         byte ptr [eax],0
1E0A7EFC 89 46 08             mov         dword ptr [esi+8],eax
1E0A7EFF 39 5E 14             cmp         dword ptr [esi+14h],ebx
1E0A7F02 75 21                jne         1E0A7F25
1E0A7F04 8B 4E 04             mov         ecx,dword ptr [esi+4]
1E0A7F07 3B 4E 08             cmp         ecx,dword ptr [esi+8]
1E0A7F0A 0F 84 24 FD FF FF    je          1E0A7C34
1E0A7F10 0F B6 01             movzx       eax,byte ptr [ecx]

It may be possible to find the source line related to this bug by searching for this code in the retail python.exe then looking up the address in the map file produced by the compiler (if enabled). I can run the script with a debug version of python.exe. Please send me information about how to download a debug version for Windows.

Note: I've tried to search this bug in the bug database, but it's not specific enough to find an exact match. No viruses nor spyware found on my machine using multiple antivirus/antispyware product. No memory errors found in 6 hours. I use LF (UNIX type) line ends on Windows to prevent errors when my scripts copied and edited on a Linux box.
msg25979 - (view) Author: Viktor Ferenczi (complex) Date: 2005-08-04 07:21
Logged In: YES 
user_id=142612

The bug could be in python.dll, of course. I need a debug version of python.dll.
msg25980 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2005-08-07 17:40
Logged In: YES 
user_id=31435

Note that it's not legal input:  there's a non-ASCII character in 
line 225, which conflicts with the explicit

# -*- coding: ascii -*-"

directive near the top of file.  Get rid of the non-ASCII 
character, and it seems to load fine.

Current Python HEAD (2.4.2 development) gives a different 
outcome:

  File "pycrash.py", line 222
SyntaxError: unknown decode error

That's peculiar too, because the offending character is 
actually on line 225, and because "unknown decode error" is 
unhelpful.  Python 2.3 at least got the line number right:

  File "pycrash.py", line 225
SyntaxError: unknown decode error

The best error report is gotten by deleting the encoding 
directive instead (using 2.4.1 here):

sys:1: DeprecationWarning: Non-ASCII character '\xc1' in file 
pycrash.py on line 224, but no encoding declared; see http
://www.python.org/peps/pep-0263.html for details

Assigning to Martin under the vague recollection that he 
knows most about the encoding implementation.
msg25981 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2005-08-08 07:17
Logged In: YES 
user_id=89016

The line number problem might be related to
http://www.python.org/sf/1178484
msg25982 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-08-25 06:07
Logged In: YES 
user_id=21627

This is now fixed for 2.4.2, which will say

  File "python_2.4.1_crash.py", line 225
SyntaxError: 'ascii' codec can't decode byte 0xc1 in
position 0: ordinal not in range(128)
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42250
2005-08-04 07:18:35complexcreate