[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c7f9e66826a0 by Mark Dickinson in branch 'default':
Issue #27662: add missing Misc/NEWS entry.
https://hg.python.org/cpython/rev/c7f9e66826a0

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-21 Thread Mark Dickinson

Mark Dickinson added the comment:

List_New_Calloc_v2.patch applied. Thanks!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-21 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cd3d079ad2b5 by Mark Dickinson in branch 'default':
Issue #27662: don't use PY_SIZE_MAX for overflow checking in List_New. Patch by 
Xiang Zhang.
https://hg.python.org/cpython/rev/cd3d079ad2b5

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Mark Dickinson

Mark Dickinson added the comment:

LGTM. Thanks!

I'll apply this later today, unless someone beats me to it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Xiang Zhang

Xiang Zhang added the comment:

Just remove it. Regenerate the patch. As for list_resize, I have already fired 
another issue27660.

--
Added file: http://bugs.python.org/file44147/List_New_Calloc_v2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Mark Dickinson

Mark Dickinson added the comment:

There's also still a use of PY_SIZE_MAX in the list_resize function. Would it 
be worth fixing that one too?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Mark Dickinson

Mark Dickinson added the comment:

Right, sorry. I'm suggesting dropping that second assertion entirely; 
essentially, we're moving the responsibility for and knowledge about overflow 
checking into the PyMem_* functions/macros (which is where it belongs), and I 
don't see a need to check the equivalent condition in list_ass_subscript.

If you do keep the second assertion, you should probably drop the `(size_t)` 
cast, so that we're not comparing signed with unsigned.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Xiang Zhang

Xiang Zhang added the comment:

Thanks for your reply Mark. But I don't understand your message about the 
assertion. There is now no assertion in PyList_New. The changed assertion 
statement is in list_ass_subscript. If this confuses you I am quite sorry to 
bring in a somewhat unrelated change. :( I just thought it's not worth to open 
another issue to change that one. Really sorry.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Mark Dickinson

Mark Dickinson added the comment:

Also, if you're switching to `PyMem_Calloc`, I'd suggest dropping the assertion 
at the end, since that's now really an assertion for logic that appears in 
`PyMem_Calloc` rather than in this function.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-19 Thread Mark Dickinson

Mark Dickinson added the comment:

The change to use PyMem_Calloc looks good to me.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-03 Thread Xiang Zhang

Xiang Zhang added the comment:

Add another PY_SIZE_MAX replacement I suggest in listobject.c.

--
Added file: http://bugs.python.org/file44002/List_New_Calloc.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-03 Thread Xiang Zhang

Changes by Xiang Zhang :


Removed file: http://bugs.python.org/file43970/List_New_Calloc.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Mark, this is your code.  Care to comment?

--
assignee:  -> mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Xiang Zhang

Xiang Zhang added the comment:

Thanks for your replies.

I update the patch with PyMem_Calloc. I think it's better than PyMem_Resize 
since we need to initialize the memory here, there is a memset(op->ob_item, 0, 
nbytes) below.

--
Added file: http://bugs.python.org/file43970/List_New_Calloc.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Martin Panter

Martin Panter added the comment:

It looks like PyMem_RESIZE() would be a truer equivalent than PyMem_Calloc(), 
since PyMem_MALLOC() does not initialize the memory. I would be happy with 
changing to that if you want.

PyMem_Malloc() has been limited to PY_SSIZE_T_MAX since Issue 2620, although 
the documentation 
 only mentions 
“size_t”. There is no match for “ssize_t” etc anywhere on that page.

--
stage:  -> patch review
versions:  -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
Removed message: http://bugs.python.org/msg271797

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

The whole computation on that line is in size_t, so the use of PY_SIZE_MAX 
seems correct.

--
nosy: +rhettinger, tim.peters

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27662] Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New

2016-08-01 Thread Xiang Zhang

New submission from Xiang Zhang:

List_New checks against PY_SIZE_MAX. The upper bound of PyMem_Malloc is 
PY_SSIZE_T_MAX.

Instead of simply changing the constant, another method is delegating overflow 
check to PyMem_Calloc, so we can avoid the check in unnecessary check in 
PyMem_Malloc. But I am not sure hiding the check in PyMem_Calloc is a good idea 
or not.

--
components: Interpreter Core
files: List_New.patch
keywords: patch
messages: 271774
nosy: martin.panter, xiang.zhang
priority: normal
severity: normal
status: open
title: Check against PY_SSIZE_T_MAX instead of PY_SIZE_MAX in List_New
type: enhancement
versions: Python 3.5, Python 3.6
Added file: http://bugs.python.org/file43962/List_New.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com