[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > We only give the reference to the caller when the newly created OrderedDict > is fully initialized (consistent). See msg246573. PyDict_New() can trigger garbage collecting and traversing , and GC have a reference to underinitialized OrderedDict and can

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread Roundup Robot
Roundup Robot added the comment: New changeset ef1f5aebe1a6 by Victor Stinner in branch '3.5': Issue #24992: Fix error handling and a race condition (related to garbage https://hg.python.org/cpython/rev/ef1f5aebe1a6 -- nosy: +python-dev ___ Python

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: > It looks to me as an ordinal bug and that is encountered only in special > circumstances with small probability. I think it can wait for 3.5.1. Ok, I agree. What about the second patch, does it look ok? -- ___

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: > See msg246573. PyDict_New() can trigger garbage collecting and traversing and > GC have a reference to underinitialized OrderedDict and can call > odict_traverse() for it. Oooh ok, I understand. I updated my patch to implement your idea. -- Added

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It looks to me as an ordinal bug and that is encountered only in special circumstances with small probability. I think it can wait for 3.5.1. -- ___ Python tracker

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: If don't initialize fields, then they will be not initialized in odict_dealloc, odict_tp_clear and odict_traverse. But _odict_FIRST(od) and od->od_weakreflist are used in these functions. I would allocate a dict for od_inst_dict before calling

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: @Serhiy: Python 3.5 is impacted. Do you consider this bug serious enough to request a pull request in Larry's branch for Python 3.5.0? -- nosy: +larry versions: +Python 3.5 ___ Python tracker

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: > If don't initialize fields, then they will be not initialized in odict_dealloc Old code initialized all fields to zero (or NULL), like "_odict_FIRST(od) = NULL;". The type allocator fills the newly allocated with zeros. So setting fields again to zero is

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: Yury wrote: > Is this something that we should ship in 3.5.0rc3? I don't think so. I agree with Serhiy who wrote: > It looks to me as an ordinal bug and that is encountered only in special > circumstances with small probability. I think it can wait for 3.5.1.

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: > I left a nitpick. In any case the patch LGTM. Ok, fixed. I pushed my fix. Thanks for the review Serhiy. -- resolution: -> fixed status: open -> closed ___ Python tracker

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
STINNER Victor added the comment: You can try the odict_failmalloc.py program with a Python compiled in debug mode to see the bug. The script requires: https://pypi.python.org/pypi/pyfailmalloc -- Added file: http://bugs.python.org/file40335/odict_failmalloc.py

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread STINNER Victor
New submission from STINNER Victor: If PyDict_New() fails (ex: memory allocation failure), odict_new() returns a new OrderedDict with an exception set. It's a bug. Attached patch fixes it. odict_new() constructor also returns NULL without destroying the newly created object if

[issue24992] collections.OrderedDict constructor (odict_new) doesn't handle PyDict_New() failure

2015-09-03 Thread Eric Snow
Eric Snow added the comment: Thanks for taking care of this, Victor (and Serhiy). :) -- stage: -> resolved type: -> behavior ___ Python tracker ___