Issue1676

classification
Title: NPE in defaultdict
Type: crash Severity: normal
Components: Library Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fwierzbicki Nosy List: MrMeanie, amak, asmeurer, emblemparade, fwierzbicki, pjenvey, zyasoft
Priority: normal Keywords: patch

Created on 2010-11-09.03:00:22 by emblemparade, last changed 2013-02-06.23:25:47 by fwierzbicki.

Files
File name Uploaded Description Edit Remove
Jython_r7169_Issue1676_fix_v1_20101109.patch MrMeanie, 2010-11-09.19:16:39 Patch to trunk (rev 7169)
Messages
msg6235 (view) Author: Tal (emblemparade) Date: 2010-11-09.03:00:20
Easy to reproduce:


>>> from collections import defaultdict
>>> x=defaultdict()
>>> x.pop(None,None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
java.lang.NullPointerException
	at org.python.core.PyDictionary.dict_pop(PyDictionary.java:602)
	at org.python.core.PyDictionary$dict_pop_exposer.__call__(Unknown Source)
	at org.python.core.PyObject.__call__(PyObject.java:408)
	at org.python.pycode._pyx20.f$0(<stdin>:1)
	at org.python.pycode._pyx20.call_function(<stdin>)
	at org.python.core.PyTableCode.call(PyTableCode.java:165)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1253)
	at org.python.core.Py.exec(Py.java:1297)
	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:215)
	at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89)
	at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70)
	at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:46)
	at org.python.util.InteractiveConsole.push(InteractiveConsole.java:110)
	at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:90)
	at org.python.util.jython.run(jython.java:320)
	at org.python.util.jython.main(jython.java:129)


Note: this bugs seems to have been introduced sometime after 2.5.2 beta.
msg6238 (view) Author: Geoffrey French (MrMeanie) Date: 2010-11-09.19:16:39
This problem appears to be caused by PyDictionary#dict_pop(), which accesses the 'map' member field directly, where it should go through the getMap() method instead.

Please find attached a patch that addresses this issue.
The patch has been tested against 'ant regrtest', and fixes the bug as described.
msg6299 (view) Author: Philip Jenvey (pjenvey) Date: 2010-12-24.00:40:46
This was broke when getMap() was added. It looks like there's potentially another use of map that should change to getMap in PyDictionary (in equals)
msg6705 (view) Author: Alan Kennedy (amak) Date: 2011-11-05.18:25:12
Is there anything we can do to move this one along?

It looks like a very straightforward issue and fix.

An updated patch against the mercurial tip, with tests, would be nice.
msg7633 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-06.23:25:47
Fixed, audited PyDictionary for other map->getMap needs, added a test in:
History
Date User Action Args
2013-02-06 23:25:47fwierzbickisetstatus: open -> closed
priority: normal
resolution: fixed
messages: + msg7633
2012-08-10 20:48:04fwierzbickisetassignee: zyasoft -> fwierzbicki
nosy: + fwierzbicki
2012-03-23 20:33:43asmeurersetnosy: + asmeurer
2011-11-05 18:25:12amaksetnosy: + amak
messages: + msg6705
2010-12-24 00:40:46pjenveysetassignee: zyasoft
messages: + msg6299
nosy: + pjenvey, zyasoft
2010-11-09 19:16:40MrMeaniesetfiles: + Jython_r7169_Issue1676_fix_v1_20101109.patch
keywords: + patch
messages: + msg6238
nosy: + MrMeanie
2010-11-09 03:00:22emblemparadecreate