[ python-Bugs-1705365 ] 'nonlocal x' at top level crashes interpreter

SourceForge.net noreply at sourceforge.net
Mon Apr 23 12:18:56 CEST 2007


Bugs item #1705365, was opened at 2007-04-23 05:20
Message generated for change (Comment added) made by ncoghlan
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1705365&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 3000
Status: Open
Resolution: None
Priority: 6
Private: No
Submitted By: John Reese (johnreese)
Assigned to: Nick Coghlan (ncoghlan)
Summary: 'nonlocal x' at top level crashes interpreter

Initial Comment:
A nonlocal declaration at the interpreter top level causes a bus error.  This happens in the p3yk branch at head (r54922).  Reporter is using MacOS 10.4.9 on Intel.  Reporter is perfectly aware that nonlocal doesn't do anything useful at the top level, but feels it should not crash the interpreter.


% gdb python3.0                                          
GNU gdb 6.3.50-20050815 (Apple version gdb-563) (Wed Jul 19 05:10:58 GMT 2006)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) run
Starting program: /Users/jtr/bin/python3.0 
Reading symbols for shared libraries . done
Python 3.0x (p3yk:54922, Apr 22 2007, 12:15:19) 
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> nonlocal x

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000004
PySet_Contains (anyset=0x0, key=0x532640) at Objects/setobject.c:2129
2129            if (!PyAnySet_Check(anyset)) {
(gdb) The program is running.  Exit anyway? (y or n) y


----------------------------------------------------------------------

>Comment By: Nick Coghlan (ncoghlan)
Date: 2007-04-23 20:18

Message:
Logged In: YES 
user_id=1038590
Originator: NO

Fixed in rev 54925 to raise SyntaxError instead of crashing.

The bug appears to have been present in the original nonlocal code - both
the original code and the refactored code checked if a nonlocal variable
was in the set of bound names without first checking that the relevant
pointer was non-NULL.

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-04-23 08:23

Message:
Logged In: YES 
user_id=849994
Originator: NO

Nick, that crash is in the symtable code you refactored with the setcomp
patch.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1705365&group_id=5470


More information about the Python-bugs-list mailing list